$(function(){
$('select[name="question.types"]').change(function(){
//var qtype=$(this).attr("displaytype");
var tdid=$(this).attr("value");
var qtype=$(this).attr("displaytype");
switchType(qtype);
});
});
var qtype=$(this).attr("displaytype");是错误的写法
jquery select change $(this).attr("displaytype")写法错误
以下是正确是写法
$(function(){
$('select[name="question.types"]').change(function(){
//var qtype=$(this).attr("displaytype");
var tdid=$(this).attr("value");
var qtype=$('select[name="question.types"] option[value="'+tdid+'"]').attr("displaytype");
switchType(qtype);
});
});
function initType(){
<c:forEach items="${typeList}" var="type">
$("<option displaytype='${type.displaytype}' value='${type.tdid}'>${type.name}</option>").appendTo($("select[name='question.types']"));
</c:forEach>
}
jquery select change $(this).attr("displaytype")写法错误
最新推荐文章于 2024-04-24 16:36:44 发布
本文介绍了一段jQuery代码中关于选择器变更事件处理的错误用法及正确的实现方式,并展示了如何通过正确的方法获取被选元素的相关属性。
3305

被折叠的 条评论
为什么被折叠?



