如何通过javascript在5秒后设置下拉列表索引 [英] How to set dropdown index after 5 second through javascript
本文介绍了如何通过javascript在5秒后设置下拉列表索引的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< asp:DropDownList ID =ddlPD1DataTextField =vc_pd_far_valueDataValueField =in_pd_far_id
Width =55runat =serverEnabled =trueonclick = SetDefaultPDValue(本); />
在这个下拉列表中,如果页面加载,我希望在5秒后将其选定的索引设置为60 !! !!
解决方案
< script type =' < span class =code-keyword> text / javascript' >
// 5000毫秒(5秒)加载完成后会触发选择第60个选项
setTimeout(function(){document.getElementById(<% = ddlPD1.ClientID %> )。options [59] .selected = true},5000);
< / script > 跨度>
<asp:DropDownList ID="ddlPD1" DataTextField="vc_pd_far_value" DataValueField="in_pd_far_id" Width="55" runat="server" Enabled="true" onclick="SetDefaultPDValue(this);" />
In this dropdown i want to set its selected index to 60 after 5 second if page loaded..!!
解决方案
<script type='text/javascript'> //5000ms (5 seconds) After loading this will fire and select the 60th option setTimeout(function(){ document.getElementById("<%= ddlPD1.ClientID %>").options[59].selected = true},5000); </script>
这篇关于如何通过javascript在5秒后设置下拉列表索引的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文