Javascript jQuery Mobile从两个autocomplete UL获取值
我有两个自动完成搜索字段,我想从这两个字段中提取值。 对于一个字段,我使用..Javascript jQuery Mobile从两个autocomplete UL获取值,javascript,jquery,jquery-mobile,Javascript,Jquery,Jquery Mobile,我有两个自动完成搜索字段,我想从这两个字段中提取值。 对于一个字段,我使用..函数(e,data)和data.input.val() 但我有一个监听器,用于两个类似的字段:$(“#搜索#1,#搜索#2”)。在(“filterableforefilter”,function(e,data) 我试过$(“#serarch_one input”).val(),但不起作用。有什么想法吗 html//搜索一个 <ul id="search_one" data-role="listview" data
函数(e,data)和data.input.val()
但我有一个监听器,用于两个类似的字段:$(“#搜索#1,#搜索#2”)。在(“filterableforefilter”,function(e,data)
我试过$(“#serarch_one input”).val(),但不起作用。有什么想法吗
html//搜索一个
<ul id="search_one" data-role="listview" data-inset="true" data-filter="true" data-filter-placeholder="Search one..." ></ul>
工作示例:
HTML:
您对此有何看法?
var search=$(“#search_one”).prev().find(“input”).val()
由于某些原因,我尝试时它起作用了…性能慢?您的解决方案比我的快,我的解决方案慢,但也适用于较旧的jQuery Mobile版本。基本上我选择兼容性而不是速度。特别是因为listview很快将被重新设计。我忘了,如果您打算只使用jQuery Mobile 1.4,请坚持您的解决方案注意。我想你的比。我只是在玩:-)不,你的m8更快:),更快总是更好,我的例子就在这里,所以任何未来的jQuery移动用户都可以使用它,而无需再发帖。
<div data-role="page" id="index" data-theme="a" >
<div data-role="header">
<h3>
First Page
</h3>
<a href="#second" class="ui-btn-right">Next</a>
</div>
<div data-role="content">
<a class="ui-btn" id="findVal">Find Value</a>
<ul id="search_one" data-role="listview" data-inset="true" data-filter="true" data-filter-placeholder="Search one..." >
<li>sdfsdfsd</li>
</ul>
</div>
<div data-role="footer" data-position="fixed">
</div>
</div>
$(document).on('pagebeforeshow', '#index', function(){
$(document).on('click', '#findVal', function(){
alert($('.ui-content').find('[placeholder="' + $('#search_one').attr('data-filter-placeholder') + '"]').val());
});
});