第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

用Hover綁定元素事件,若要寫的樣式很多。用attr()方法讀取樣式表類名。為什么現(xiàn)在反而沒反應(yīng)了?

用Hover綁定元素事件,若要寫的樣式很多。用attr()方法讀取樣式表類名。為什么現(xiàn)在反而沒反應(yīng)了?

淡水狗 2017-07-11 14:52:04
<!DOCTYPE?html> <html> <head> ????<meta?http-equiv="Content-type"?content="text/html;?charset=utf-8"?/> ????<title></title> ????<style> ????.left?div?{ ????????width:?350px; ????????height:?150px; ????????padding:?5px; ????????margin:?5px; ????????border:?1px?solid?#ccc; ?????????background:?#bbffaa; ????} ???? ????p?{ ????????height:?50px; ????????border:?1px?solid?red; ????????margin:?30px; ????} ????.bjcolor{?background:?#fff;} ????</style> ????<script?src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script> </head> <body> ????<h2>.hover()方法</h2> ????<div?class="left"> ????????<div?class="aaron1"> ????????????<p>觸發(fā)hover事件</p> ????????</div> ????</div> ????<script?type="text/javascript"> ????$("p").hover( ????????function()?{ ????????????$(this).css("background",?'red'); ????????}, ????????function()?{ ????????????$(this).attr("bjcolor");??//這里換成獲取樣式表里面的樣式,或換成.addClass()方法都沒反應(yīng) ????????} ????); ????</script> </body> </html> ————————————————————————————————————————————————————— 是不是要結(jié)合removeClass()才行? ????$('p').hover( ????????function(){ ????????????$(this).addClass("add"); ????????}, ???????? ????????function(){ ?????????????$(this).removeClass("add"); ????????} ????????)
查看完整描述

3 回答

已采納
?
__innocence

TA貢獻313條經(jīng)驗 獲得超208個贊

$(this).css("backgroundcolor","#fff");

bjcolor并不是屬性,而是class

查看完整回答
反對 回復(fù) 2017-07-11
  • 淡水狗
    淡水狗
    那直接獲取樣式不行嗎? 像這樣 試了一遍反應(yīng)不了 $('p').hover( function(){ $(this).attr("class1"); }, function(){ $(this).attr("class2"); } )
  • __innocence
    __innocence
    你的class名不是屬性名。class和attribute是不一樣的。 <input type="text" class="left" id="btn"/> class是left,attribute是type,class和id
?
qq_薄言_0

TA貢獻1條經(jīng)驗 獲得超0個贊

。。。

查看完整回答
反對 回復(fù) 2017-07-11
  • 3 回答
  • 0 關(guān)注
  • 1933 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號