Reputation: 46322
I have the following in my .delegate:
link_id is the id of the link.
I need to next say if that id started with RPwd then do something.
Why doesn't ^= work in this case?
var link_id = $(this).attr('id'); //capture the id of the clicked link
if (link_id ^= "RPwd") {
Upvotes: 3
Views: 1914
Reputation: 34917
As far as I know ^=
is not an operator in javascript. That could be your problem.
I think you are looking for
if ($(this).is('[id^="RPwd"]')) {
}
Upvotes: 2
Reputation: 270767
The starts with ^=
selector is a jQuery object selector. You're doing a string comparison, and can therefore use indexOf()
if (link_id.indexOf("RPwd") === 0) {
// Match
}
Upvotes: 3