How to retrieve which link has been pressed?
On my webpage I've got a couple of links (in this example two), when one of the links is pressed the Jquery will notice the click.
Now I need to alter my coding so that I can retrieve which of the links has been pressed and pass that information to my php script.
Problem is that I don't know how to retrieve which link has been pressed.. I hope someone can help me out with it..
My coding:
- <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script>
$().ready(function(){
$(".button").click(function() {
var button = this;
var target1 = $( 'input[name=target1]' ).val();
var target2 = $( 'input[name=target2]' ).val();
- var dataString = 'target1=' + target1 + '&target2='+target2;
$.ajax({
url: 'msgsrv.php',
type: 'POST',
dataType: 'html',
data: dataString,
success: function(result) {
$("div.test").html(result).fadeIn(100);
// $("div.test").html(result);
- }
});
});
});
- </script>
<div class="test"></div>
<form name="contact">
<span class="vId">
<div id="target1" class="button"><span><a href="#">Click 1</a></span></div>
</span>
<span class="gc_Name">Bartlett-White</span>
<span class="vId">
<div id="target2" class="button"><span><a href="#">Click 2</a></span></div>
</span>
<span class="gc_Name">Landingham Bends</span>
</form>