gpt4 book ai didi

javascript - jQueryMobile 无法获取 iPhone 上输入文本框的值

转载 作者:行者123 更新时间:2023-12-03 21:19:16 25 4
gpt4 key购买 nike

我有一个带有一些输入的简单 jQM 表单,问题是在 iPhone 上测试时无法通过 JS 检索输入的值,主要桌面浏览器可以正常工作。

这是表格的一部分:

<div data-role="fieldcontain">
<input type="text" name="fname" id="fname" />


<input type="text" name="lname" id="lname" />

<input type="button" value="Go" onclick="validate()" />
</div>

Javascript:

function validate()
{
alert('value: ' + $('#fname').val());
}

警报的字面意思是:

值:

还尝试使用传统的 .value 方法。

使用的版本:

<script type="text/javascript" src="http://code.jquery.com/jquery-1.5.2.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/mobile/1.0a4.1/jquery.mobile-1.0a4.1.min.js"></script>

编辑:添加了更多代码以进行澄清。

最佳答案

确保您已准备好文档:

$(function(){
alert($('#fname').val()); //should be nothing bc the input has no value yet
});

关于javascript - jQueryMobile 无法获取 iPhone 上输入文本框的值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6495852/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com