Reputation: 277
<div class="content">
<div style="background:url(...jpg) no-repeat #01AEF0;" class="slide-small">
<div><strong>Title</strong></div>
<div class="read_more"><a class="t_10" href="http://example.com/">Read More</a></div>
</div>
</div>
When I click on the div
that has a class="content"
my code calls function. When I click on Read More the function is called and after that the new page opens. I need not to call the function, only open the href
.
Upvotes: 0
Views: 58
Reputation: 205987
$('.read_more a').click(function(e){
e.stopPropagation();
});
events
like click
bubble to ancestor elements. To prevent that event bubble further than your a
element ... read this: http://api.jquery.com/event.stopPropagation/
Upvotes: 5
Reputation: 73896
$('div.content').click(function(e){
if(e.target === this) {
// Only then call your function
}
});
Upvotes: 1