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

yundejia

关注

阅读 65

2023-04-23


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

0 0 举报