jQuery $("#field") 为空? [英] jQuery $("#field") is null?
本文介绍了jQuery $("#field") 为空?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有月份的选择框.
I have a selectbox with month periods in it.
这是我的代码:
$(function(){
$("#ppsub_ppterm_id").change(function(){
var term = this.options[this.selectedIndex].text;
if(term == "Eenmalig"){
$(".idealtd").show();
}else{
$(".idealtd").hide();
//$("#ppsub_amount option:selected").val('anders');
}
});
});
<select name="ppsub_ppterm_id" class="ppsub_ppterm_id"
id="ppsub_ppterm_id" style="width: 100px; font-size: 11px;">
<option value="M">Maand</option>
<option value="K">Kwartaal</option>
<option value="H">Halfjaar</option>
<option value="J">Jaar</option>
<option selected value="E">Eenmalig</option>
</select>
但是当我加载我的页面时,我马上得到一个错误:
But when i load my page i staight away get an error:
$("#ppsub_ppterm_id") 为空
$("#ppsub_ppterm_id") is null
第 17 行
有什么想法吗?
推荐答案
听起来 JQuery 没有正确加载.您使用的是哪个源/版本?
Sounds like JQuery isn't loading properly. Which source/version are you using?
另外,也可能是命名空间冲突,因此请尝试显式使用 jQuery
而不是 $
.如果可行,您可能希望使用 noConflict 来确保其他代码正在使用 $
不会中断.
Alternatively, it could be namespace collision, so try using jQuery
explicitly instead of $
. If that works, you may like to use noConflict to ensure the other code that's using $
doesn't break.
这篇关于jQuery $("#field") 为空?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文