簡體   English   中英

jQuery點擊事件單選按鈕

[英]jquery tap event radio button

點擊事件似乎不適用於單選按鈕。

$(document).on("tap","input[type=radio]",function(e){//do something});

此事件不會觸發。 對於單選按鈕,單擊事件似乎運行良好。

點擊事件似乎適用於所有其他類型的按鈕。

完整的HTML

 <!DOCTYPE html> <html> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script> <script> $(document).ready(function(){ $(document).on("tap","input[type=radio]",function(e){alert("tapped");}); }); </script> <body> <form action="#"> <input type="radio" name="Gender" value="Male">Male<br> <input type="radio" name="Gender" value="Female">Female<br> <input type="submit"> </form> <p>Click on the submit button to submit the form.</p> </body> </html> 

如果我點擊更換水龍頭同一工作正常。

點擊事件運行正常,否則就不是問題了。

您缺少的是jQuery移動庫:

<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>

您可以從W3Schools中查看此示例

即使tap事件等效於jquery中的click事件,您也需要添加移動庫以使tap事件起作用。

查看適用於您的案例的此JSFiddle

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM