John
John

Reputation: 1003

Jquery Mobile remember if href is clicked

I am trying to figure out if there is a way to remember if a href has been clicked, on jquery mobile for dynamic href

When hrefs are generated in a loop with multiple parameter tagged on.

For example

      for (var j=0; j<total; j++) {
 var Url = "page.html?id="+ + encodeURIComponent(id);

 var $newContent ="<a href='"+Url+"'><div>ID='"+id+"'</div></a>"
}

And there are many of these hrefs are generated, but what can i tag on to allow me to distinguish if a specific id has been clicked?

Upvotes: 0

Views: 35

Answers (1)

Arjun Rajagopalan
Arjun Rajagopalan

Reputation: 107

You could use a function on the href, that sends the href that is pressed to the log file, and from that you can decode as to which tag is been clicked upon.

<a href="page.html?id=1" onclick=function_getVal(1)>
<a href="page.html?id=1" onclick=function_getVal(2)>
<a href="page.html?id=1" onclick=function_getVal(3)>
<script>
 function_getVal(id){
  alert(id);
 }
</script>

or call this function_getVal() in the url generator itself.

Upvotes: 1

Related Questions