我有以下代码:JavaScript代码没有运行
...<some code>...
...<elements load>...
<script type="text/javascript">
var selected_city = document.getElementById('jform_city').value;
var selected_province=document.getElementById('jform_province').value;
<!-- set the onchange property for all options in provice to activate getCities() -->
document.getElementById('jform_province').onchange = function() {
getCities();
}
if(selected_province != ''){
getCities();
}
</script>
...<more elements load>....
<script type="text/javascript">
alert("TEST");
document.getElementById(selected_city).selected="1";
</script>
它选择从下拉列表中我有一个选择,问题是,如果我删除警报(“”)它停止工作出于某种原因,有什么想法?
我试了这些,他们没有工作,我也试图把一切都在页面(元素负荷后右)中间的警报前,那么一些其他元素的负载,则调用在的结束页面(所以叫我的元素加载之后肯定只配备),它仍然不能正常工作,请参阅改变的代码。 – Mankind1023 2013-02-13 21:05:45
我还试图在window.onload =函数();在完成所有事情之后应该运行的文档的末尾,同样的问题。 – Mankind1023 2013-02-13 21:26:04