1、邏輯很簡單,如果是圖片的話,就是不停地?fù)Q圖片。比如點(diǎn)擊女之后,女這塊圖片變成綠色圖片,男那邊圖片變成黑色圖片。

在云龍等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站制作、做網(wǎng)站 網(wǎng)站設(shè)計(jì)制作按需規(guī)劃網(wǎng)站,公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),高端網(wǎng)站設(shè)計(jì),成都全網(wǎng)營銷,外貿(mào)營銷網(wǎng)站建設(shè),云龍網(wǎng)站建設(shè)費(fèi)用合理。
2、如果用符號做邏輯也是一樣的,點(diǎn)擊之后兩個項(xiàng)目都變色,一個變成綠色、另一個變成黑色。
3、具體的JavaScript代碼如下圖所示。
本文實(shí)例講述了js實(shí)現(xiàn)選中復(fù)選框文字變色的方法。分享給大家供大家參考。具體如下:
這里實(shí)現(xiàn)選中復(fù)選框時,文字加上一個背景色,變通一下,還是很有用的。
運(yùn)行效果如下圖所示:
在線演示地址如下:
具體代碼如下:
html
head
title選中復(fù)選框文字變色/title
style
.checkbox
{
background-Color:e-xpression(this.checked?'yellow':'buttonface');
}
/style
/head
script
function
chaCloor(field){
var
pig
=
field.checked;
pig?field.nextSibling.style.backgroundColor="skyblue":field.nextSibling.style.backgroundColor="white";
}
/script
body
table
height=48
width=136
tr
tdinput
type="checkbox"
onClick="chaCloor(this)"span 網(wǎng)頁特效/span/td
/tr
tr
tdinput
type="checkbox"
onClick="chaCloor(this)"span源碼下載/span/td
/tr
tr
tdinput
type="checkbox"
onClick="chaCloor(this)"span編程軟件/span/td
/tr
/table
/body
/html
希望本文所述對大家的javascript程序設(shè)計(jì)有所幫助。
var lastcc = "btitle1";//有輸入框,不管多少個,都一點(diǎn)會有btitle1,所以初始值設(shè)這個最好了
function listSel(obj) {
if (document.getElementById(obj.name).style.backgroundColor == "white") {
//先變白,就可以避免第一次點(diǎn)擊的就是btitle1,而無法變灰
//原先第一次執(zhí)行下面這句代碼時lastcc為 undefined
//document.getElementById(lastcc).style 報(bào)錯
//alert(lastcc);這句及以下代碼沒有被執(zhí)行,所以alert提示undefined
document.getElementById(lastcc).style.backgroundColor = "white";
document.getElementById(obj.name).style.backgroundColor = "silver";
alert(lastcc);//第一次執(zhí)行的時候
lastcc = obj.name;
document.getElementById("btSel").value = document.getElementById(obj.name).value;
} else {
document.getElementById(obj.name).style.backgroundColor = "white";
alert(lastcc);
document.getElementById("btSel").value = "";
}
}
window.onload=function(){
var h=new Date().getHours();
var o=document.documentElement||document.body;
if(h8){
o.style.backgroundColor="red";
o.style.color="white";
}else if(h16){
o.style.backgroundColor="green";
o.style.color="black";
}else{
o.style.backgroundColor="yellow";
o.style.color="brown";
}
}
當(dāng)前文章:javascript變色,javascript顏色代碼
網(wǎng)站URL:http://chinadenli.net/article16/dsidgdg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供云服務(wù)器、虛擬主機(jī)、移動網(wǎng)站建設(shè)、網(wǎng)站維護(hù)、軟件開發(fā)、網(wǎng)站建設(shè)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)