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>

当我单击div具有class="content"我的代码调用功能的那个时。当我点击阅读更多时,该函数被调用,然后新页面打开。我不需要调用该函数,只需打开href.

4

2 回答 2

5
$('.read_more a').click(function(e){
   e.stopPropagation();
});

eventsclick泡沫到祖先元素。为了防止该事件泡沫超出您的a元素...阅读此内容: http: //api.jquery.com/event.stopPropagation/

于 2013-05-01T13:03:52.490 回答
1
$('div.content').click(function(e){
   if(e.target === this) {
        // Only then call your function
   }
});
于 2013-05-01T13:06:12.497 回答