标签: jquery internet-explorer cross-browser sizzle
所以我试图让jQuery做出以下选择:
$("a[href=#/example]")
我有一个锚<a href="#/example">ex</a>。
<a href="#/example">ex</a>
当我在chrome,IE8,FF或其他浏览器中尝试使用此选择器时,它工作正常,但是当我在IE6 / 7和其他旧浏览器中进行测试时,选择器不起作用,因为浏览器解释了anchor的href属性为http://example.com/#/example
http://example.com/#/example
为所有浏览器解决此问题的优雅方法是什么?
答案 0 :(得分:4)
使用ends-with attribute selector:
$("a[href$=#/example]")