点击事件在jQuery Mobile中不触发? [英] Click event not firing in jQuery Mobile?

查看:112
本文介绍了点击事件在jQuery Mobile中不触发?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

查看此小提琴: http://jsfiddle.net/Bg9Zx/5/

相关代码:

<fieldset data-role="controlgroup" data-type="horizontal" id="locate-me">
<input type="checkbox" name="loc" id="loc" />
<label for="loc">Locate me</label>
</fieldset>
$("#loc").click(function(){
   alert('locate clicked!');
});

.click()事件为什么不触发?如果我不引用jQuery Mobile,则效果很好.

Why isn't the .click() event firing? Works perfectly fine if I don't reference jQuery Mobile.

谢谢!

推荐答案

您所引用的错误. #loc指的是元素的ID,请改用它.

You are referecing it wrong. #loc refers to an ID of an element use this instead.

<label class="test" for="loc">Locate me</label>

$(".test").click(function(){
   alert('locate clicked!');
});

这篇关于点击事件在jQuery Mobile中不触发?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆