简体   繁体   English

如果跨度显示设置为内联执行此操作

[英]If span display set to inline do this

I'm working on a .net website that validates an input and if it fails adds an inline style "display:inline;" 我正在开发一个验证输入的.net网站,如果失败则添加内联样式“display:inline;”

Im trying to use jQuery to see this style and add a class to the respective input field. 我试图使用jQuery来查看此样式并将类添加到相应的输入字段。

if(!!$('span.errorp').length ){
   alert('hi');
} 

the above is what im currently using to ensure i can target the correct tag which works, 以上是我目前正在使用的,以确保我可以定位正常的标签工作,

I guess i need something similar too... 我想我也需要类似的东西......

if(!!$('span.errorp').display:inline ){
    alert('hi');
} 

Try the following 请尝试以下方法

if ($('span.errorp').css('display') === 'inline') {
  ...
}

You can use something like: 您可以使用以下内容:

$('span.errorp').css('display', 'inline');

It's not necessary to check for length. 没有必要检查长度。 If there are no matches, nothing happens. 如果没有匹配,则没有任何反应。

if($('span.errorp[style=display:inline]')) {
    // do stuff
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 跨度显示内联在 safari 上根本不显示 - span display inline not displaying at all on safari ReactJS在onMouseOver上设置display ='inline' - ReactJS set display='inline' onMouseOver 如何水平扩展内联跨度的可点击区域? - How do I horizontally extend the clickable area of an inline span? 如何设置跨度背景颜色,使其在整个行中为背景着色,如div中所示(显示:块;不是选项) - How do I set span background-color so it colors the background throughout the line like in div (display: block; not an option) 根据 span 标签中数字的大小设置显示属性 - Set display property depending on the size of the number in the span tag 需要将1个span的样式设置为display ::由span的set设置为display:none的图库在页面加载时被阻止 - Need to set 1 span's style to display:block on page load for an image gallery made up of span's set to display:none 如何使图像将类设置为display:none,然后将特定的id设置为display:inline - How can i make an image set a class to display:none and then set a specific id to display:inline 聚合物内联条件式,或者,如何显示加载图像? - Polymer inline conditional, or, how do I display a loading image? 如何显示未定义数量的div内联? - How do I display an undefined number of divs inline? 如何显示跨度 - How to display it to span
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM