brokencode Posted July 10, 2010 Share Posted July 10, 2010 I am trying to take a typical link, and make it so that when clicked, the value of the HREF is passed to a javascript function - the trick is, and I would really like to do so without having to reference the id of the <a> tag. Is there some way to make the link refer to it's own HREF value onClick? Non-working example for visualization purposes: <a href="http://www.testsite.com" onClick="checklink(self.href)"> I would like it to pass "http://www.testsite.com" to the checklink() function. Any help is greatly appreciated. Thank you for looking! Link to comment https://forums.phpfreaks.com/topic/207378-obtaining-href-contents-without-setting-an-id/ Share on other sites More sharing options...
Zane Posted July 10, 2010 Share Posted July 10, 2010 use this.href instead of self.href Link to comment https://forums.phpfreaks.com/topic/207378-obtaining-href-contents-without-setting-an-id/#findComment-1084210 Share on other sites More sharing options...
brokencode Posted July 10, 2010 Author Share Posted July 10, 2010 Win! Thank you so much! Link to comment https://forums.phpfreaks.com/topic/207378-obtaining-href-contents-without-setting-an-id/#findComment-1084216 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.