Reputation: 8754
I'm using $(this).attr("href");
to select the href attribute value of the clicked element, but I need to select only the part after the last '=' symbol.
Example:
href="index.php?con=123&id=123&sel=heyhey"
I only need the last part of the href that is 'heyhey'
How can I select this??
Upvotes: 3
Views: 1509
Reputation: 3533
var s = "index.php?con=123&id=123&sel=heyhey";
var i = s.lastIndexOf("=");
alert(s.substr(i+1, s.length));
EDIT:
doesn't even need of jQuery
Upvotes: 0
Reputation: 86805
Without regex -
var parts = $(this).attr('href').split('=');
var part = parts[parts.length - 1];
Upvotes: 3