如何通过指定其id来获取css属性

时间:2011-10-09 15:00:55

标签: javascript jquery

Padding or margin value in pixels as integer using jQuery 看完上面的答案后。其中一个用户已经开始使用这些

 alert($("a").css("margin-top"));

现在我想做这些

 alert($("#cool").css("margin-top")); ' #cool is my table id <table id="cool">

但它不起作用。如何通过指定标识来获取标记的css属性?

1 个答案:

答案 0 :(得分:0)

好像你没有把你的代码放在pageLoad事件中:

$(function(){ 
   alert($("#cool").css("margin-top"))
})

或者您忘了将jQuery.js集成到您的页面中。