select文本框架(change事件)改变另外一个select的值

mac2022-06-30  80

$('select[name=adults]').bind('change', function() { var $value = $(this).val(); if ($value >= 1) { var html = ''; for (i = 1; i <= $value; i++) { html = html + '<option value="' + i + '">' + i + '</option>'; } $('select[name=infants] option').each(function() { if ($(this).val() > 0) { $(this).remove(); } }); $(html).appendTo('select[name=infants]') } else { var html = ''; html = html + '<option value="0">0</option>'; html = html + '<option value="1">1</option>'; $(html).appendTo('select[name=infants]') } });

转载于:https://www.cnblogs.com/hgj123/p/3725192.html

相关资源:垃圾分类数据集及代码
最新回复(0)