can we add textbox and button to select 2

落爺英雄遲暮 提交于 2019-12-09 23:11:13

问题


here i attached the code of select can we add the textbox and button into select2 elements. here which i used a code:

<select style="width:100%"  id="e9">

    <option value="volvo">Suger</option>
    <option value="saab">Saab</option>
    <option value="opel">Opel</option>
    <option value="audi">Audi</option>

</select>

here i attached the output image how i really want:


回答1:


here is the answer...

 $(".select2-drop").append('<div><input type="text" style="width: 86%;padding: 9px;"name="lname"><input class="PrimaryBtn" type="submit" value="Add"></div>');



回答2:


$("#e9").select2("container").find("div.select2-drop").append('<div><input type="text" name="lname"><input class="PrimaryBtn" type="submit" value="Add"></div>');

may be this will help, it will add to the needed select2 only



来源:https://stackoverflow.com/questions/20438381/can-we-add-textbox-and-button-to-select-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!