Reputation: 1589
i have a href like this:
<a href="images/prevFeb-1.jpg" name="day-1" onclick="swap(this); return false;">
<img src="images/thumbFeb-1.jpg" width="50" height="50" alt="" title="thumbFeb-1.jpg" />
</a>
when the user clicks on a thumbnail, the images get swap. i will like to get the href name upon on click. and i will explode("-",$hrefName) and like to get the value "1"
any ideas many thanks!
Upvotes: 1
Views: 1510
Reputation: 811
Is this what you're looking for?
function swap(element) {
var name = element.attributes.getNamedItem("name").value;
var nameValue = name.split('-')[1];
// do something with it...
}
More about getNamedItem()
here: http://www.w3schools.com/DOM/met_nodemap_getnameditem.asp
Upvotes: 1
Reputation: 9942
If you have the hyperlink name fixed then better use substring on the name of your link.
Upvotes: 0