0
<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.

0

2 Answers 2

5
$('.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/

Sign up to request clarification or add additional context in comments.

Comments

1
$('div.content').click(function(e){
   if(e.target === this) {
        // Only then call your function
   }
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.