开发者

Query:adding empty list item

开发者 https://www.devze.com 2023-02-11 06:20 出处:网络
I\'m updating a select box from it\'s document\'s child (thickbox) var opt = \"<option value=\'8\'>TEST<option>\";

I'm updating a select box from it's document's child (thickbox)

var opt = "<option value='8'>TEST<option>";
parent.jQuery("#my_teams_list").prepend(opt开发者_JS百科);

Here "my_teams_list" is the id of the parent document's select box.

While doing this an empty list item is added inside of the select box.

I don't know why. Please clear me. thanks in advance.


try: EDIT

parent.jQuery("#my_teams_list").prepend($("<option></option>").text("test").val("test"));


Depending on what your list is (assume <select>) you want to prepend child element not just text so instead of prepending "TEST" prepend "<option>TEST</option>".

0

精彩评论

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