开发者

Call id textbox when use autocomplete jquery?

I have a textbox use autocomplete, when i load ajax to call textbox with same id from another page, autocomplete not usable in this textbox.

Example:

$(document).ready(function() {

  $("#myid").autocomplete("search.php", {
      width: 200,
      matchContains: true,
      selectFirst: false
  });
});

textbox1 with id="myid" ready when page load first <-- autocomple use well

textbox2 with same id="myid", just appear when i call ajax to load from开发者_运维问答 another page,textbox2 will repalce textbox1 <--- textbox2 can not read function to use autocomple.

Maybe ready(function() just work when page load?

Could write it same named function for insert on event (onkeyup,..) in textbox?

Exp: input type="text" id="myid" onkeyup="namedfunction('myid')" or onkeyup="namedfunction(this.value)"?

I don't know why? Anyone please help me?

Thanks!


3tgz12


your page cannot have same ids so you can leverage class here i.e use class="myid" instead of id="myid" and change the code to class selector. hope it will help you

$(".myid").autocomplete("search.php", {
      width: 200,
      matchContains: true,
      selectFirst: false
  });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜