是否可以在JQuery移动表单标签中使用链接? [英] Is it possible to use links in a JQuery Mobile Form Label?
本文介绍了是否可以在JQuery移动表单标签中使用链接?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
使用jQuery Mobile时遇到一个奇怪的问题.
I have just encountered a strange problem when using jQuery Mobile.
我在表单元素标签内有一个链接-精确的复选框标签,但该链接不起作用.
I have a link inside a form element label - a checkbox label to be exact but the link does not work.
我尝试阅读文档,但似乎找不到任何内容.
I have tried reading the docs but can't seem to find anything on it.
这是我的标记:
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<input type="checkbox" class="cbox" name="OptIn" id="OptIn"/>
<label for="OptIn">Receive E-mails From Us</label>
<input type="checkbox" value="1" class="cbox" name="tandc" id="tandc"/>
<label for="tandc">I agree to the <a href="/tandcs.html" target="_BLANK" >Terms & Conditions</a></label>
</fieldset>
</div>
单击链接后,它仅会切换复选框状态.
When the link is clicked it just toggles the checkbox state.
更新
刚刚意识到我可以通过右键单击来打开链接,但是显然是在不太有用的移动设备上....
Just realised I can open the link by right clicking but obviously on a mobile device that's not very useful....
推荐答案
这是针对移动和非移动浏览器的正确解决方案
this is the correct solution for mobile and non mobile browsers
$('.ui-checkbox a').bind("tap click", function( event, data ){
event.stopPropagation();
$.mobile.changePage($(this).attr('href'));
});
这篇关于是否可以在JQuery移动表单标签中使用链接?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文