i'm having this markup:
<a href='#' onclick='loadpage(121);'>
<a href='#' onclick='loadpage(122);'>
<a href='#' onclick='loadpage(123);'>
my question: how can i select the 2nd link object by jQuery using the id 122?
i've tried something like $("a[onclick=loadpage(122)]")
but didn't work.
thx
Try adding in the ;
and placing the loadpage(122);
in single quotes.
Try it out: http://jsfiddle.net/PQB5U/
$("a[onclick='loadpage(122);']")
All these ways works. Use the one whichever fits your need.
$('a[onclick="loadpage(122);"]') // match entire onclick value
$('a[onclick^="loadpage(122)"]') // match from the left of onclick value
$('a[onclick*="loadpage(122)"]') // match anywhere in onclick value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With