I have a list of auto-generated anchor tags from my code-behind which HREFs are a combination of # and the ID from an object extracted from a database.
What I need to do is to get the HREF using Javascript and put in to a function.
function someFunction(hrefValue){
// Run some functionallity here
}
I imagine that I have to, in my code-behind, add an onclick to my auto-generated anchor tags:
Controls.Add(new LitarelControl("<a href='#"+ item.ID+"' onclick='someFunction();'>Hi</a>");
A friend of mine told me that I HAVE to specify which anchor tag’s HREF I want, but as all of my anchor tags in my custom control runs the same Javascript, I can’t specify one single HREF.
Any thoughts or suggestions?
Do pass
thisas parameter intosomeFunction();.Demo: http://www.jsfiddle.net/5HXK2/