I’m trying to append a url with an id (just as a test) in my joomla installation using the following code.
jQuery('body').click(function(e) {
e.preventDefault();
window.location = jQuery(this).attr('href') + '#test';
});
Now this works to an extent except it adds the string “undefined” right before “#test”.
Example:
http://www.website.com/articles/undefined#test
Why is “undefined” being added, and is there a way to stop it?
Thanks
the body tag doesn’t have an href attribute. Use
instead.