Eam*_*orr 3 mobile jquery jquery-mobile
问候,
我有以下jQuery Mobile代码:
<div data-role="content">
A confirmation code has been sent to your mobile phone via SMS
<br><br>
To proceed, please enter the 3-digit confirmation code below:
<br>
<input id="verifySMS_code" type="text" /><br>
<a id="verifySMS_submit" href="#" data-role="button">Submit</a>
</div>
Run Code Online (Sandbox Code Playgroud)
这是我的javascript:
$(document).ready(function(){
$("#verifySMS_submit").live("click",function() {
alert('hi');
var code=$('input#verifySMS_code').val();
alert(code);
});
});
Run Code Online (Sandbox Code Playgroud)
'hi'出现在第一个警告框中,但是''出现在第二个警告框中 - 即完全空白!
我试过document.getElementById('verifySMS_code')也无济于事.
我甚至尝试过jquery mobile 1.0a3pre
这对我来说是一个非常严重的问题,我不知道如何解决它.
我希望有人能帮帮忙.
提前谢谢了,
安装萤火虫
测试它
<input id="verifySMS_code" type="text" value="someoldvalue" />
和
$(document).ready(function(){
$("#verifySMS_submit").bind("submit",function() {
console.log($('#verifySMS_code'));
var code=$('#verifySMS_code').val();
console.log(code);
});
});
Run Code Online (Sandbox Code Playgroud)
这就是为什么:
value=输入将显示是否与所获得的价值或把你输入的内容到输入元素(jQuery Mobile的基础上输入的东西)的问题live()那里blur输入上的事件,所以当你单击其他内容时,它会发生,而不是在此之前console.log($('input#verifySMS_code'));
将在控制台中弹出您的元素.如果空数组弹出 - 没有这样的元素,这是一个选择器问题.测试具有重复ID的输入.
这显示了所有ID:$('input').each(function(){console.log($(this).attr('id'));});
在firebug中运行它,它也将指向DOM,因此您可以在HTML选项卡中单击并找到它们.