开发者

finding css display value of a div

I have some divs that have a css display of either 'block' or 'none' :

$("#divMTR").css("display", "none");
$("#divST").css("display", "block");

Is it possible to check wha开发者_如何学编程t the css display value is for a div in JQuery? I would like to check what the value is, and on a certain condition change it.


You can get the value of a CSS proeprty by writing $(...).css('propertyName').

You may also want to write if ($('#divST').is(':visible')) (or :hidden), using jQuery's .is() method (which checks whether an element matches a selector) and the :visible and :hidden pseudo-selectors.


Just use :

alert($("#divMTR").css("display"));

This will return the value instead of modifying it. It works for most Jquery methods.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜