1

How to select attriute value with jQuery/CSS

<dt onclick="GomageNavigation.navigationOpenFilter('price-left');">

As regular it must be db[onclick="GomageNavigation.navigationOpenFilter('price-left')"] but is not working. Any idea?

2
  • 3
    why not just give it an id or class? Commented Jan 30, 2014 at 10:20
  • 1
    Selecting an element that has a specific onclick attribute? That's very fragile and a bad practice. Commented Jan 30, 2014 at 10:23

1 Answer 1

4

It should be dt, not db also missing double quote at the end

Change

db[onclick="GomageNavigation.navigationOpenFilter('price-left')]

to

  dt[onclick="GomageNavigation.navigationOpenFilter('price-left');"]
// ^here                     also missing quote and semicolum    ^^

You need to escape the quotes when selecting in jQuery so it would look like this

$("dt[onclick=\"GomageNavigation.navigationOpenFilter('price-left');\"]")

DEMO

Sign up to request clarification or add additional context in comments.

2 Comments

i saw the missing quote. However this is not working
@Stan updated answer you were missing semicolum aswell

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.