开发者

Is something like this valid at all- div.find and input id

Hello I have something like

 div.find("input").autocomplete({

.....

and am wondering if I can add an input id t开发者_开发技巧o the element...

ie.

 div.find("input#good")

thanks!


An input tag can have an id on it like: <input id="good" type="text">. If you did that, then you can just use this jQuery $("#good") to find it and that should be simpler than div.find("input#good") and faster because finding an id is natively supported by the browser.

There can only be one object in a page with the id="good", so there's no reason to use div.find on it unless you only want it found if it's in a more narrow context.


Try $("input[name=inputname]"); instead. Getting values will be easier later down the road if you reference them like that.

oh and your inputs need a name attribute: <input type="text" name="inputname" /> so that you can use them for actual forms.


Just $("#good") will be enough and this is assuming you have unique id on the page to all the dom elements which have ids.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜