【发布时间】:2011-03-07 18:03:30
【问题描述】:
<select id="townid" name="townid">
<s:iterator value="townsForLanding">
<option value="<s:property value="id"/>"><s:property value="name"/></option>
</s:iterator>
</select>
我有这样的功能:
$(function(){
var central = $('#townid option:contains("Central")');
if(central){
central.insertAfter('select option:first-child');
}
});
这个函数可以做到这一点:如果该 dropdwonlist 有一个“Central”元素,则将其放在第一个选项之后。
我的问题是如何在下拉列表加载后运行该函数。
我试过了:
$('#townid').one("click", function() {
$('#townid option:contains("Central")').insertAfter('select option:first-child');
});
但是该代码有一个问题:列表来自 Central 的位置不正确,然后它排在第二位,我的意思是它没有快速刷新它,所以我看到了列表的变化。加载后点击之前我想要它?
【问题讨论】:
-
执行你的意思是加载??
标签: jquery html struts2 drop-down-menu