js/jq修改或获取CSS属性,DOM属性

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);
 });   
});

 

 

 

你可能感兴趣的:(css)