i have two span's and where i have a custom attribute. I want to get the value of it by clicking <a>.Here is my html
<span data="<?php echo $key; ?>"><?php echo $answer['vote']; ?></span>
<a href="#" class="tup" rel="<?php echo $answer['id']; ?>"><span class="glyphicon glyphicon-thumbs-up design-thumbs" id="thumbs-up-ico"></span></a>
Jquery
$(document).ready(function() {
$( ".tup" ).click(function(event) {
event.preventDefault();
var key = $('span').attr('data');
alert(key);
});
Here i get undefined in alert.Where is my error?Thanks