jQuery选择器中的冒号 [英] Colon in Jquery selector
本文介绍了jQuery选择器中的冒号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已将我的jquery从1.4更新到2.1,并开始出现错误.
I have recntly updated my jquery from 1.4 to 2.1 and an error started appeared.
在我的代码中,我有一部分选择带有ID的元素.
In my code I have a part where I select the elements with by an id.
jQuery("*[id^=name:]")
产生一个错误,但是之前没有错误(1.4)
That produces an error, however there were no errors before(1.4)
如果我逃脱了结肠,错误就会消失.他们是否在最新版本中添加了新内容,或者仅仅是我的代码中的错误?
If I escape the colon than the error disappears. Have they added anything new in the latest version or is it just a bug in my code?
推荐答案
您可以像字符串文字一样包装属性值
you can wrap the attribute value like a string literal
jQuery('*[id^="name:"]')
演示:小提琴
这篇关于jQuery选择器中的冒号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文