国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > JavaScript > 正文

JS實(shí)現(xiàn)簡單面向?qū)ο蟮念伾x擇器實(shí)例

2019-11-20 10:14:07
字體:
供稿:網(wǎng)友

本文實(shí)例講述了JS實(shí)現(xiàn)簡單面向?qū)ο蟮念伾x擇器。分享給大家供大家參考,具體如下:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=gb2312" /><title>Untitled Document</title></head><body><script type="text/JavaScript"><!--var colorPicker = function(idStr){ this.colorPool = ["#000000","#993300","#333300","#003300","#003366","#000080","#333399","#333333","#800000","#FF6600","#808000","#008000","#008080","#0000FF","#666699","#808080","#FF0000","#FF9900","#99CC00","#339966","#33CCCC","#3366FF","#800080","#999999","#FF00FF","#FFCC00","#FFFF00","#00FF00","#00FFFF","#00CCFF","#993366","#CCCCCC","#FF99CC","#FFCC99","#FFFF99","#CCFFCC","#CCFFFF","#99CCFF","#CC99FF","#FFFFFF"]; this.initialize(idStr);}colorPicker.prototype = { initialize: function(idStr){  var count=0;  var html = '';  var self = this;  html+= '<table cellspacing="5" cellpadding="0" border="2" bordercolor="#000000" style="cursor:pointer;background:#ECE9D8" mce_style="cursor:pointer;background:#ECE9D8" >';  // html+= '<tr><td align="center" colspan="8" width="160" height="20" id="currentColor" bgcolor="#ffffff">當(dāng)前顏色</td></tr>';  for(i=0;i<5;i++)  {   html+= "<tr>";   for(j=0;j<8;j++)   {    html+= '<td align="center" width="20" height="20" style="background:'+ this.colorPool[count]+'" mce_style="background:'+ this.colorPool[count]+'" unselectable="on"> </td>';    count++;   }   html+= "</tr>";  }  html+= '</table>';  this.trigger = document.getElementById(idStr);  this.div = document.createElement('div');  this.div.innerHTML = html;  var tds = this.div.getElementsByTagName('td');  for(var i=0,l=tds.length;i<l;i++){   tds[i].onclick = function(){    self.setColor(this.style.backgroundColor);   }  }  this.div.id = 'myColorPicker';  this.trigger.parentNode.appendChild(this.div);  this.div.style.position = 'absolute';  this.div.style.left = this.trigger.offsetLeft + 'px'  this.div.style.top = (this.trigger.clientHeight + this.trigger.offsetTop)+ 'px';  //this.hide();  this.trigger.onclick = function(){   if(self.div.style.display == 'none'){    self.show();    return false;   }else{    self.hide();    return false;   }  } }, setColor : function(c){  this.hide();  document.getElementById('demo').style.backgroundColor = c //proEditor.setColor(c); //自己定義函數(shù)決定setColor的功能 }, hide : function(){  this.div.style.display = 'none' }, show : function(){  this.div.style.display = 'block' }}// --></script><div ><a href="#" mce_href="#" onclick="initColorPicker();return false" id="demo" style="position:absolute;left:200px">顏色選擇</a></div><script type="text/javascript"><!--function initColorPicker(){ picker = new colorPicker('demo');}// --></script></body></html>

對(duì)于JS顏色工具感興趣的朋友可參看本站在線工具

RGB顏色編碼生成器

RGB顏色查詢對(duì)照表_顏色代碼表_顏色的英文名稱大全

在線網(wǎng)頁配色工具

更多關(guān)于JavaScript相關(guān)內(nèi)容可查看本站專題:《JavaScript切換特效與技巧總結(jié)》、《JavaScript查找算法技巧總結(jié)》、《JavaScript動(dòng)畫特效與技巧匯總》、《JavaScript錯(cuò)誤與調(diào)試技巧總結(jié)》、《JavaScript數(shù)據(jù)結(jié)構(gòu)與算法技巧總結(jié)》、《JavaScript遍歷算法與技巧總結(jié)》及《JavaScript數(shù)學(xué)運(yùn)算用法總結(jié)

希望本文所述對(duì)大家JavaScript程序設(shè)計(jì)有所幫助。

發(fā)表評(píng)論 共有條評(píng)論
用戶名: 密碼:
驗(yàn)證碼: 匿名發(fā)表
主站蜘蛛池模板: 湖口县| 仁布县| 阿瓦提县| 吉木萨尔县| 吉隆县| 兰考县| 荣成市| 桐庐县| 曲周县| 武汉市| 炎陵县| 长泰县| 文成县| 望奎县| 江西省| 宁蒗| 隆德县| 依安县| 海原县| 双鸭山市| 涪陵区| 磐石市| 北碚区| 桑日县| 元江| 南皮县| 慈溪市| 长岭县| 社旗县| 闽清县| 郎溪县| 丹阳市| 宜兰县| 广东省| 德州市| 双柏县| 桓仁| 义乌市| 清流县| 霍林郭勒市| 称多县|