0
点赞
收藏
分享

微信扫一扫

jquery select change $(this).attr("displaytype")写法错误

yundejia 2023-04-23 阅读 65


$(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>

}

举报

相关推荐

0 条评论