Javascript 使用select tag change listner更新dom
获取以下代码:Javascript 使用select tag change listner更新dom,javascript,ajax,jquery,Javascript,Ajax,Jquery,获取以下代码: <form action="./index.html" method="get"> <select class=" locationdropdown selectdropdown pull-right" id="prayerMethod"> <option value="ISNA">ISNA</option> <option
<form action="./index.html" method="get">
<select class=" locationdropdown selectdropdown pull-right" id="prayerMethod">
<option value="ISNA">ISNA</option>
<option value="MWL">MWL</option>
<option value="Egypt">Egypt</option>
<option value="Makkah">Makkah</option>
<option value="Karachi">Karachi</option>
<option value="Tehran">Tehran</option>
<option value="Jafari">Jafari</option>
</select>
<input type="submit" value="SUBMIT" style="display:none;">
</form>
<script>
var mySelect = document.getElementById("prayerMethod");
$(mySelect).change(function(){
// $(this).parent('form').submit();
// alert(mySelect.options[mySelect.selectedIndex].value );
prayTimes.setMethod(mySelect.options[mySelect.selectedIndex].value );
});
</script>
伊斯纳
MWL
埃及
麦加
卡拉奇
德黑兰
贾夫利
var mySelect=document.getElementById(“祈祷方法”);
$(mySelect).change(function(){
//$(this.parent('form').submit();
//警报(mySelect.options[mySelect.selectedIndex].value);
setMethod(mySelect.options[mySelect.selectedIndex].value);
});
我希望它用输入到prayTimes()方法中的select标记给出的新值更新dom。我该怎么做?您到底想在DOM中更新什么?您使用的函数是什么?为什么要将
document.getElementById()
的结果传递到jQuery选择器中,而不是简单地将$(“#祈祷方法”)
?@DavidThomas您是对的。我只是快速而肮脏的尝试things@bagonyivar times=prayTimes.getTimes(日期,[43,-80],-5)
需要一种计算方法,因此为什么.setMethod()是。但是我想更新live方法,以更改计算和时间的输出