Bug Tracker

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#14236 closed bug (notabug)

Inconsistency with attributes selectors

Reported by: rellect@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.10.1
Keywords: Cc:
Blocked by: Blocking:


There is a little inconsistency between Chrome and Firefox with attributes selectors

For the two following examples, chrome could run it, but firefox not:

$('a[rel=nofollow]').on('click', function(event) {
$('a[rel=nofollow"]').on('click', function(event) {

Firefox stopped the script with error about unrecognized expression.

Finally what worked for both was

$("a[rel='nofollow']").on('click', function(event) {

Change History (2)

comment:1 Changed 10 years ago by Rick Waldron

Resolution: notabug
Status: newclosed

Yes, quotes are required. Says so in the docs: http://api.jquery.com/category/selectors/attribute-selectors/

comment:2 Changed 10 years ago by dmethvin

If it's a bare identifier the quotes are optional. But you can't ever half-quote, which seems to be the problem in at least one of them. There's not enough information in the code snippet to know what "could run it" means so it would be best to ask for help on a forum.

Note: See TracTickets for help on using tickets.