the code below is suppose to remove #approve and #deny and echo what the user has pressed when one of the links are pressed.
<html>
<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"></script>
<script type="text/javascript">
$(function(){
$('#approve').click(function(){
$('#approve').unbind('click');
$('#deny').unbind('click');
$('.rare').html('Approved!');
});
return false;
});
$('#deny').click(function(){
$('#approve').unbind('click');
$('#deny').unbind('click');
$('.rare').html('Denied!');
});
return false;
});
})
</script>
</head>
<body>
<div class="rare">
<a href id="approve">Approve</a>
<a href id="deny">Deny</a>
</div>
</body>
</html>
but it doesnt seem to work, i am new to jquery so i dont understand why it doesnt work. jquery is hosted my google
Your nesting looks broken, try this:
Also, I won’t make assumptions about why you’re returning false, but if you’re wanting to prevent the default
clickevent behavior, this is the preferred approach:Cheers