0

I have several href tag, and it redirects to different Jsp. I want to send an integer along with URL.

Assume I am in a.jsp, Inside I have an href tag like below

<a href='app/b?num=1' class='passid'>Link to b.jsp</a> // Is this correct syntax to pass value 
<a href='app/c?num=2' class='passid'>Link to c.jsp</a>
<a href='app/d?num=3' class='passid'>Link to d.jsp</a>

If I click Link to b.jsp , then inside b.jsp ready method I have to take that num value that sends through href tag.

$(document).ready(function() {
  needs to check num equals to 1 or not
}
Ganesan S
  • 85
  • 1
  • 3
  • 13
  • Possible duplicate of [How to get the value from the GET parameters?](https://stackoverflow.com/questions/979975/how-to-get-the-value-from-the-get-parameters) – Taplar Oct 26 '18 at 14:41

1 Answers1

0

Like so:

$(document).ready(function() {
  $("a").click(function(){  
    var href= $(this).attr("href"); 
    var id = href.substring(href.length - 1)
    alert(id)
  });
});
clearshot66
  • 2,292
  • 1
  • 8
  • 17