jQuery a[href=#/example] does not select all matching anchors - cross-browser issue
So I'm trying to get jQuery to make the following selection:
$("a[href=#/example]")
and I have an anchor <a href="#/example">ex</a>
.
When I try this selector out in chrome, IE8开发者_StackOverflow社区, FF, or other browsers it works fine, but when I goto test it in IE6/7, and other older browsers, the selector doesn't work because the browser interprets the anchor's href attribute as http://example.com/#/example
What's a graceful way to solve this issue for all browsers?
Use the ends-with attribute selector:
$("a[href$=#/example]")
精彩评论