
Originally Posted by
centered effect
For jQuery:
Code JavaScript:
<a href="#" class="noAlert">Click</a>
<a href="#" class="noAlert">Click</a>
<a href="#" class="noAlert">Click</a>
<a href="#" class="mylink">I haz no alert</a>
<a href="#">Click</a>
<a href="#">Click</a>
<a href="#" class="mylink">I haz no alert either</a>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script>
$('a:not(.mylink)').click(function() {
alert('Alerting!');
});
</script>
Hi Again
I tried your example, its alerting only when I click on the target A tag. It should alert only if not clicked on the A tag. I am using the following example:
Code:
<script src="jquery.js"></script>
<script>
$(function () {
$('a:not(.mylink)').click(function() {
alert('Alerting!');
});
});
</script>
<A class="mylink" HREF="#">Click here</a> tag.
<A class="mylink2" HREF="#">Click here</a> tag.
Bookmarks