2013-01-25 59 views
1

创建一个listview..In的ListView我把一个button..like如何在jQuery Mobile中防止默认的listview点击?

<ul class="ui-listview"> 
<li> 
    <p>HEllo</p> 
    <input type='button' id='btn1'> 
    </li> 

<li> 
    <p>Hiii</p> 
    <input type='button' id='btn2'> 
    </li> 
</ui> 

现在我想点击该按钮的事件,并停止列表视图的默认点击...所以怎么样了其可能的jQuery的?

+1

['event.preventDefault'](http://api.jquery.com/event.preventDefault/)? – peterm

+0

但我在哪里呢? – Piyush

+1

['event.stopPropagation'](http://api.jquery.com/event.stopPropagation/),['event.preventDefault'](http://api.jquery.com/event.preventDefault/) – peterm

回答

1

$("input[type=button]").click(function(event){ 
    event.stopPropagation(); 
    //your code goes here 
}); 

Here is jsFiddle根据您的标记。