[英]jQuery Mobile onclick event doesn`t remove class ui-disabled
Before I started coding with jQuery Mobile the function which I have used to remove the class "ui-disabled" has totally runned. 在我开始使用jQuery Mobile进行编码之前,我用来删除“ ui-disabled”类的功能已完全运行。 But now it only gives me back the alert message...
但是现在它只给了我警报消息...
HTML-Code: HTML代码:
<div data-role="navbar" style="padding-bottom:50px;">
<ul>
<li> <a href="#" id="choice1" class="ui-disabled" data-role="button" data-icon="star" onclick="radio1()">Simple</a></li>
</ul>
</div>
<a href="quiz.html" id="next" class="ui-disabled" data-role="button" onclick="next()">Send</a>
Java-Script: Java脚本:
function radio1 ()
{
alert("test");
$('#next').removeClass('ui-disabled');
}
I also know that it is better if I use this code example but it also doesn`t work.. 我也知道,如果我使用此代码示例会更好,但它也无法正常工作。
$("#choice1").click(function (e) {
e.preventDefault();
alert("heymr.");
});
I Hope someone can help me. 我希望有一个人可以帮助我。 Thanks in advance!
提前致谢! :)
:)
You have declared the function incorrectly, so it is not visible: 您错误地声明了该函数,因此它不可见:
JSFiddle: http://jsfiddle.net/ntk9v2je/1/ JSFiddle: http : //jsfiddle.net/ntk9v2je/1/
radio1 = function()
{
alert("test");
$('#next').removeClass('ui-disabled');
}
This declares radio1 as a function on the default scope ( window
in this case). 这将radio1声明为默认作用域(在这种情况下为
window
)上的函数。
As for the $("#auswahl1").click
example: It works just fine once you add in the removeClass
call: 至于
$("#auswahl1").click
示例:一旦添加removeClass
调用,它就可以正常工作:
JSFiddle: http://jsfiddle.net/ntk9v2je/2/ JSFiddle: http : //jsfiddle.net/ntk9v2je/2/
For either problem , also make sure you have correctly included jQuery (before these code snippets). 对于这两个问题,还请确保已正确包含jQuery(在这些代码段之前)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.