在jQuery中通过样式选择器查找元素 [英] Find element by style selector in jquery
本文介绍了在jQuery中通过样式选择器查找元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试查找具有特定样式的元素,并将其样式更改为其他样式.
I am trying to find an element with a particular style and change its style to something else.
这是html元素
<table style='width: 555px;'>
<tr>
<td>blablabla</td>
</tr>
</table>
现在,我正在尝试查找宽度为555px的表格,并使用jquery将其更改为650px.
Now I am trying to find the table with width 555px and change it to 650px using jquery.
$('table[style*=width:555px]').css("width", "610px");
但是这不起作用.有人可以提出一个主意吗?
But this is not working. Can somebody spark an idea please?
注意:由于某些原因,我无法更改html.
NOTE: For some reason I cannot change the html.
推荐答案
提防空格:)
您应该用"
或'
引用该值.
$('table[style*="width: 555px"]').css("width", "610px");
如果它在IE中不起作用,您可以尝试删除该空间吗? (完全未经测试!)
If it does not work in IE, you could try to remove the space? (totally untested!)
$('table[style*="width: 555px"],table[style*="width:555px"]')
.css("width", "610px");
这篇关于在jQuery中通过样式选择器查找元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文