views:

81

answers:

2

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??

+1  A: 

Without regex -

var parts = $(this).attr('href').split('=');
var part = parts[parts.length - 1];
Eran Galperin
Jonathan
Eran Galperin
A: 
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

Im0rtality