JQuery實(shí)現(xiàn)動(dòng)態(tài)適時(shí)改變字體顏色的方法
本文實(shí)例講述了JQuery實(shí)現(xiàn)動(dòng)態(tài)適時(shí)改變字體顏色的方法。分享給大家供大家參考。具體分析如下:
JQuery動(dòng)態(tài)適時(shí)改變字體的顏色,Ajax的效果類似,在文本框輸入文字,再選擇色塊,輸入的文字就會(huì)變成色塊標(biāo)示的顏色值,很不錯(cuò)的效果吧。如果運(yùn)行有錯(cuò),請(qǐng)刷新一次頁(yè)面即可。
<html xmlns="http://www.w3c.org/1999/xhtml">
<head>
<title>JQuery動(dòng)態(tài)改變字體顏色</title>
<meta charset="gb2312" />
<style type="text/css">
h1 {
font:bold 15px/19px Georgia, serif;
}
p {margin:0;}
#colorselections a {
border:2px solid #fff;
margin-right:4px;
display:block;
float:left;
}
a img {
border:1px solid #fff;
width:22px;
height:22px;
vertical-align:bottom;
}
#colorselections{zoom:1}
#colorselections a.on {
border:2px solid #d5680d;
}
#previewer {
margin:26px 0 20px 0;
padding:6px;
clear:left;
font:bold 19px/25px Verdana;
border:1px solid #ccc;
width:80%;
}
</style>
<script type="text/javascript" src="js/jquery1.3.2.js"></script>
<script type="text/javascript">
$(function(){
$("#inputText").keyup(function(){
$("#previewer").empty();
$("#previewer").text($(this).attr("value"));
});
});
$(function(){
$("#colorselections a").click(function(){
$(this).addClass("on").siblings().removeClass("on");
$("#previewer").css("color",$(this).css("background-color"))
});
});
</script>
</head>
<body>
<h1>請(qǐng)輸入文字</h1>
<input type="text" id="inputText" value="" />
<h1>請(qǐng)選擇顏色</h1>
<p>
<span id="colorselections">
<a href="#" style="background-color:#000000;" class="on">
<img src="/jscss/demoimg/201006/space.gif" class="colorbox" alt="Black" />
</a>
<a href="#" style="background-color:#003399;" class="">
<img src="/jscss/demoimg/201006/space.gif" class="colorbox" alt="Light Blue" />
</a>
<a href="#" style="background-color:#5E5E5E;" class="">
<img src="/jscss/demoimg/201006/space.gif" class="colorbox" alt="Medium Gray" />
</a>
<a href="#" style="background-color:#00524E;" class="">
<img src="/jscss/demoimg/201006/space.gif" class="colorbox" alt="Dark Teal" />
</a>
<a href="#" style="background-color:#258B86;" class="">
<img src="/jscss/demoimg/201006/space.gif" class="colorbox" alt="Light Teal" />
</a>
<a href="#" style="background-color:#DA7E33;" class="">
<img src="/jscss/demoimg/201006/space.gif" class="colorbox" alt="Orange" /></a>
<a href="#" style="background-color:#198541;" class="">
<img src="/jscss/demoimg/201006/space.gif" class="colorbox" alt="Green" />
</a>
</span>
</p>
<br clear="both" />
<p id="previewer"></p>
</body>
</html>
希望本文所述對(duì)大家的jQuery程序設(shè)計(jì)有所幫助。
- jquery實(shí)現(xiàn)的隨機(jī)多彩tag標(biāo)簽隨機(jī)顏色和字號(hào)大小效果
- jQuery插件echarts設(shè)置折線圖中折線線條顏色和折線點(diǎn)顏色的方法
- jQuery與js實(shí)現(xiàn)顏色漸變的方法
- jQuery實(shí)現(xiàn)的文字hover顏色漸變效果實(shí)例
- jquery實(shí)現(xiàn)實(shí)時(shí)改變網(wǎng)頁(yè)字體大小、字體背景色和顏色的方法
- jQuery實(shí)現(xiàn)鼠標(biāo)滑過(guò)Div層背景變顏色的方法
- jQuery獲取樣式中顏色值的方法
- jQuery獲取隨機(jī)顏色的實(shí)例代碼
相關(guān)文章
解決jQuery插件tipswindown與hintbox沖突
先掃下盲:tipswindown是jQuery的彈窗插件,可以使用url或當(dāng)前頁(yè)元素顯示在模擬層中;hintbox是jQuery的類似Google Suggestions插件。2010-11-11(jQuery,mootools,dojo)使用適合自己的編程別名命名
我們經(jīng)常用一些別名方法來(lái)使用自己喜歡的js 庫(kù)。學(xué)習(xí)javascript的朋友可以參考下。2010-09-09jquery實(shí)現(xiàn)手機(jī)端單店鋪購(gòu)物車結(jié)算刪除功能
本文主要介紹了js實(shí)現(xiàn)手機(jī)端單店鋪購(gòu)物車結(jié)算刪除功能的示例代碼,具有很好的參考價(jià)值,下面跟著小編一起來(lái)看下吧2017-02-02jQuery延遲執(zhí)行的實(shí)現(xiàn)方法
這篇文章主要介紹了jQuery延遲執(zhí)行的實(shí)現(xiàn)方法,結(jié)合簡(jiǎn)單實(shí)例形式分析了jQuery針對(duì)無(wú)法同步執(zhí)行的情況使用延遲執(zhí)行的操作技巧,需要的朋友可以參考下2016-12-12jquery.fastLiveFilter.js實(shí)現(xiàn)輸入自動(dòng)過(guò)濾的方法
這篇文章主要介紹了jquery.fastLiveFilter.js實(shí)現(xiàn)輸入自動(dòng)過(guò)濾的方法,涉及jquery鼠標(biāo)事件及字符串遍歷的相關(guān)技巧,簡(jiǎn)單實(shí)用,需要的朋友可以參考下2015-08-08運(yùn)用jQuery定時(shí)器的原理實(shí)現(xiàn)banner圖片切換
banner圖片切換效果,在一些企業(yè)網(wǎng)站上經(jīng)常會(huì)碰到,本文運(yùn)用jQuery定時(shí)器的原理實(shí)現(xiàn)banner圖片切換,感興趣的朋友可以學(xué)習(xí)下2014-10-10