2011-10-09 32 views
0

Padding or margin value in pixels as integer using jQuery 阅读上述答案后。一个用户的exaplained这些如何通过指定其编号获取css属性

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

现在我想做这些

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

,但没有奏效。如何通过指定其标识来获取标签的CSS属性?

+0

您展示的方式应该可行。那桌子上可能没有'保证金'? –

+0

请说明它是否会导致错误(&不警告)或警告“未定义”? –

+0

它没有任何提醒 – niko

回答

0

好像你没有把你的代码中的页面加载事件中:

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

或者你忘了的jquery.js集成到您的网页。