指的是这个链接:
https://gist.github.com/awgreenblatt/4499835
如果我有3个不同的输入文字,我该如何设置值:
<input id="product_search[1]" type="text" data-provide="typeahead"><br>
<div id="product[1]" style="border-width:1; padding: 5px; border-style: solid"></div><br><br>
<input id="product_search[2]" type="text" data-provide="typeahead"><br>
<div id="product[2]" style="border-width:1; padding: 5px; border-style: solid"></div><br><br>
<input id="product_search[3]" type="text" data-provide="typeahead"><br>
<div id="product[3]" style="border-width:1; padding: 5px; border-style: solid"></div><br>
谢谢
答案 0 :(得分:0)
取自您提供的链接
var products = [
{
id: 0,
name: "Deluxe Bicycle",
price: 499.98
},
{
id: 1,
name: "Super Deluxe Trampoline",
price: 134.99
},
{
id: 2,
name: "Super Duper Scooter",
price: 49.95
}
];
$(document).ready(function(){
$('#product_search1').val(products[0].name);
$('#product_search2').val(products[1].name);
$('#product_search3').val(products[2].name);
});
我用jsFiddle测试的事实,我的解决方案不会与您的ID一起。您可能想要重命名输入ID
的jsfiddle。 http://jsfiddle.net/KVS5F/