js/jq修改或擷取CSS屬性,DOM屬性

來源:互聯網
上載者:User

CSS

js擷取屬性

document.getElementById(id).currentStyle.屬性;

js修改屬性

document.getElementById(id).style.屬性 = 值;

DOM(例href屬性)

JS擷取href

var imgUrl = document.getElementById(id).href;

JQ擷取href

$(document).ready(function(){
 $("a").hover(function(){
  var imgUrl = $(this).attr("href");    alert(imgUrl);
 });   
});

 

 

 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.