📄 代码清单3-16.htm
字号:
lang=EN-US style='font-size:9.0pt'>#046<span style='mso-spacerun:yes'>
</span><span
style='mso-spacerun:yes'> </span>//</span><span
style='font-size:9.0pt;font-family:宋体;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman"'>颜色渐变,最终变化为背景色</span><span lang=EN-US
style='font-size:9.0pt'><o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#047<span
style='mso-spacerun:yes'> </span><span style='mso-tab-count:
2'> </span><span
style='mso-spacerun:yes'> </span>function fade(<span class=SpellE>fieldId</span>){<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#048<span
style='mso-spacerun:yes'> </span><span style='mso-tab-count:
2'> </span><span
style='mso-spacerun:yes'> </span><span style='mso-tab-count:1'> </span><span
style='mso-spacerun:yes'> </span><span class=SpellE>var</span> field
= <span class=SpellE>document.getElementById</span>(<span class=SpellE>fieldId</span>);<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#049<span
style='mso-spacerun:yes'> </span><span style='mso-tab-count:
2'> </span><span
style='mso-spacerun:yes'> </span>if(<span class=SpellE>color_b</span><256){<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#050<span
style='mso-spacerun:yes'> </span><span style='mso-tab-count:
3'> </span><span
style='mso-spacerun:yes'> </span><span class=SpellE>field.style.backgroundColor</span>='#'+<span
class=SpellE>color_rg+intToHex</span>(<span class=SpellE>color_b</span>);<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#051<span
style='mso-spacerun:yes'> </span><span style='mso-tab-count:
3'> </span><span
style='mso-spacerun:yes'> </span><span class=SpellE>color_b</span>
+=step;<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#052<span
style='mso-spacerun:yes'> </span><span style='mso-tab-count:
3'> </span><span
style='mso-spacerun:yes'> </span>timers = <span
class=SpellE>setTimeout</span>("fade("+<span class=SpellE>fieldId</span>+")",
1000);<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#053<span
style='mso-spacerun:yes'> </span><span
style='mso-tab-count:2'> </span>}else{<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#054<span
style='mso-spacerun:yes'> </span><span style='mso-tab-count:
2'> </span><span
style='mso-spacerun:yes'> </span><span style='mso-tab-count:
1'> </span><span class=SpellE>clearTimeout</span>(timers);<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#055<span
style='mso-spacerun:yes'> </span><span style='mso-tab-count:
2'> </span><span
style='mso-spacerun:yes'> </span><span style='mso-tab-count:
1'> </span><span class=SpellE>color_b</span> = 0;<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#056<span
style='mso-spacerun:yes'> </span><span
style='mso-tab-count:2'> </span>}<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#057<span
style='mso-spacerun:yes'> </span>}<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#058<span style='mso-spacerun:yes'>
</span><span
style='mso-spacerun:yes'> </span>//</span><span
style='font-size:9.0pt;font-family:宋体;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman"'>将</span><span lang=EN-US
style='font-size:9.0pt'>10</span><span style='font-size:9.0pt;font-family:宋体;
mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman"'>进制整数值转变为</span><span
lang=EN-US style='font-size:9.0pt'>16</span><span style='font-size:9.0pt;
font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:
"Times New Roman"'>进制值</span><span lang=EN-US style='font-size:9.0pt'><o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#059<span
style='mso-spacerun:yes'>
</span>function <span class=SpellE>intToHex</span>(<span class=SpellE>intValue</span>){<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#060<span
style='mso-spacerun:yes'> </span><span
style='mso-tab-count:1'> </span><span class=SpellE>var</span>
<span class=SpellE>hexValue</span>;<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#061<span
style='mso-spacerun:yes'> </span><span
style='mso-tab-count:1'> </span><span class=SpellE>var</span>
<span class=SpellE>hexStr</span> = '0123456789abcdef';<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#062<span
style='mso-spacerun:yes'> </span><span
style='mso-tab-count:1'> </span><span class=SpellE>var</span>
mod = <span class=SpellE>Math.floor</span>(<span class=SpellE>parseInt</span>(<span
class=SpellE>intValue</span>)/16);<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#063<span
style='mso-spacerun:yes'>
</span><span class=SpellE>var</span> <span class=SpellE>leftValue</span> = <span
class=SpellE>parseInt</span>(<span class=SpellE>intValue</span>) - 16*mod;<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#064<span
style='mso-spacerun:yes'>
</span><span class=SpellE>hexValue</span> =<span class=SpellE>hexStr.charAt</span>(mod)+<span
class=SpellE>hexStr.charAt</span>(<span class=SpellE>leftValue</span>);<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#065<span
style='mso-spacerun:yes'>
</span>return <span class=SpellE>hexValue</span>;<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#066<span
style='mso-spacerun:yes'> </span><span style='mso-tab-count:
2'> </span>}<o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#067<span
style='mso-spacerun:yes'> </span></script><o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#068<span
style='mso-spacerun:yes'> </span><body><o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#069<span style='mso-spacerun:yes'>
</span><span style='mso-spacerun:yes'> </span><input type=button
value=</span><span style='font-size:9.0pt;font-family:宋体;mso-ascii-font-family:
"Times New Roman";mso-hansi-font-family:"Times New Roman"'>开始更新</span><span
lang=EN-US style='font-size:9.0pt'> <span class=SpellE>onclick</span>=<span
class=SpellE>sendQuery</span>()><p><o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#070<span style='mso-spacerun:yes'>
</span><span style='mso-spacerun:yes'> </span></span><span
style='font-size:9.0pt;font-family:宋体;mso-ascii-font-family:"Times New Roman";
mso-hansi-font-family:"Times New Roman"'>随机更新文本框:</span><span lang=EN-US
style='font-size:9.0pt'><<span class=SpellE>br</span>><o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#071<span
style='mso-spacerun:yes'> </span>1:<input
type="text" id="0"><<span class=SpellE>br</span>><o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#072<span
style='mso-spacerun:yes'> </span>2:<input
type="text" id="1"><<span class=SpellE>br</span>><o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#073<span
style='mso-spacerun:yes'> </span>3:<input
type="text" id="2"><<span class=SpellE>br</span>><o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#074<span
style='mso-spacerun:yes'> </span>4:<input
type="text" id="3"><<span class=SpellE>br</span>><o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#075<span
style='mso-spacerun:yes'> </span>5:<input
type="text" id="4"><<span class=SpellE>br</span>><o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#076<span
style='mso-spacerun:yes'> </span>6:<input
type="text" id="5"><<span class=SpellE>br</span>><o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#077<span
style='mso-spacerun:yes'> </span><body><o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:18.0pt;background:#E6E6E6'><span
lang=EN-US style='font-size:9.0pt'>#078<span
style='mso-spacerun:yes'> </span></html><o:p></o:p></span></p>
<p class=MsoNormal style='text-indent:21.0pt'><span lang=EN-US><o:p> </o:p></span></p>
</div>
</body>
</html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -