jQuery-如何获取样式显示属性“无/阻止" [英] Jquery - How to get the style display attribute "none / block"

查看:81
本文介绍了jQuery-如何获取样式显示属性“无/阻止"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有一种获取样式的方法:显示属性,该属性要么不包含任何内容,要么不包含任何内容?

Is there a way to get the style: display attribute which would have either none or block?

DIV:

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

     <p class="cellphone" style="display: block;">Text</p>

</div>

我知道有一种方法可以确定DIV是否隐藏,但在我的情况下,该div是动态注入的,因此它始终显示为可见的false,因此我不能使用它:

I know that there is a way to find out if the DIV is hidden or not but in my case this div is dynamically injected so it always shows up as visible false thus I cannot use that :

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

我可以使用以下命令获得结果"display:block":

I am able to get the result "display:block" using :

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

有没有办法只获取值"block"或"none",或者有更好/更有效的方法来做到这一点?

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

推荐答案

您可以尝试:

$j('div.contextualError.ckgcellphone').css('display')

这篇关于jQuery-如何获取样式显示属性“无/阻止"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆