I searched Google many times and found many similar questions around www, but not everything that nailed my problem to the ground.
I have a jquery function that gets the href attribute from a binding tag that should return this value - #SomeIDHere
It works fine in my development environment, but when it is produced, it returns the current URI + #ID. I need only the #ID part for all other scripts to work as intended.
This is how I get href, now all I have to do is split the href value and get the # ID part.
function myFunction(sender) {
var id = sender.getAttribute('href');
alert(id);
}
I tried this solution , which was a brilliant start, but when I tried to implement it, I only got undefined values or JavaScript errors.
Some of the things I tried:
function myFunction(sender) {
var id = sender.getAttribute('href');
var newID = $(id).search.split('#')[1];
alert(id);
}
function myFunction(sender) {
var id = sender.getAttribute('href');
var newId = $(id).split('#')[1];
}
function myFunction(sender) {
var id = sender.getAttribute('href');
var newId = $(sender)[0].search.split('#')[1];
}
, ? .