Jquery - How to get the "none / block" style display attribute

Is there a way to get a style: display attribute that either won't or is locked?

DIV:

<div id="ctl00_MainContentAreaPlaceHolder_cellPhone_input_msg_container" class="Error cellphone" style="display: block;"> <p class="cellphone" style="display: block;">Text</p> </div> 

I know there is a way to find out if the DIV is hidden or not, but in my case this div is dynamically entered, so it always shows as visible false, so I can not use it:

 $j('.Error .cellphone').is(':hidden') 

I can get the result of "display: block" using:

 $j('div.contextualError.ckgcellphone').attr('style') 

Is there a way to get only the value "block" or "none" or is there a better / more efficient way to do this?

+67
jquery coding-style attributes
Dec 09 '09 at 17:14
source share
4 answers

You can try:

 $j('div.contextualError.ckgcellphone').css('display') 
+105
Dec 09 '09 at 17:16
source share

If you are using jquery 1.6.2 you only need code

 $('#theid').css('display') 

eg:

 if($('#theid').css('display') == 'none'){ $('#theid').show('slow'); } else { $('#theid').hide('slow'); } 
+65
Jul 13 '11 at 19:37
source share

this is the correct answer

 $('#theid').css('display') == 'none' 

You can also use the following line to determine if it is a display block or none

 $('.deal_details').is(':visible') 
+27
May 23 '12 at 11:23
source share

My answer

 /** * Display form to reply comment */ function displayReplyForm(commentId) { var replyForm = $('#reply-form-' + commentId); if (replyForm.css('display') == 'block') { // Current display replyForm.css('display', 'none'); } else { // Hide reply form replyForm.css('display', 'block'); } } 
+2
Sep 04 '15 at 16:13
source share



All Articles