2

I'm pretty new to Jquery Mobile and I'm trying to trig a tap event. It's working. If I click the div the class will be added. But if I click the a tag the class will be added to the a tag too. How can I make the class be added just to the div, no matter if I click the div or a?

Here is the code:

<div id="measure-success">
<div class="measures"><a href="">How long to prepare each campaign?</a></div>
<div class="measures"><a href="">Size of Database</a></div>
</div>

$(function() {  
   $("#measure-success .measures").bind("tap", tapHandler);
    function tapHandler (event) {
        $(event.target).addClass("tap");
    }
});
4

1 回答 1

1

更改$(event.target)$(this) 保持其余代码不变。

于 2013-09-12T01:07:35.060 回答