var spaces="----";
var category_name="category";
var category_text=spaces+category_name;
alert(category_text);
$('select').append($("<option>").attr({'value' : inserted_id , 'label' : category_name}).text(category_text));
This code includes option to my listbox.
The problem in Internet Explorer 7. The option is included, but the expected display is '----category'
. But Internet Explorer 7 displays only category
in options. Since I am using tree order I need to have hyphens before so开发者_如何学Gome category. How can I solve it in Internet Explorer 7?
Try this:
$('select')
.append($("<option />")
.attr({'value' : inserted_id ,
'label' : category_name,
'text' : category_text
}));
or this:
$('select')
.append($("<option />")
.attr({'value' : inserted_id ,
'label' : category_text
}));
You set label to category_name. It seems like if you set the lable it displays this instead of the inner HTML.
精彩评论