<html><head><script type="text/javascript" class="lazyload" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB/AAffA0nNPuCLAAAAAElFTkSuQmCC" data-original="/jquery/jquery.js"></script><script type="text/javascript">$(document).ready(function(){ var fields = $("#fm").serializeArray();jQuery.each( fields, function(i, field){ $("#results").append(field.value + " ");});$("#fm").change(function(){ fields = $("#fm").serializeArray();$("#results").text("");jQuery.each( fields, function(i, field){ $("#results").append(field.value + " ");}); });});</script></head><body><p id="results"><b>Results:</b> </p><form id="fm"> <select name="single"> <option>Single</option> <option>Single2</option> </select> <select name="multiple" multiple="multiple"> <option selected="selected">Multiple</option> <option>Multiple2</option> <option selected="selected">Multiple3</option> </select><br/> <input type="checkbox" name="check" value="check1" checked="checked"/> check1 <input type="checkbox" name="check" value="check2" /> check2 <input type="radio" name="radio" value="radio1" checked="checked"/> radio1 <input type="radio" name="radio" value="radio2"/> radio2</form></body></html> 1、 change事件2、 append 增加3var fields = $("#fm").serializeArray();jQuery.each( fields, function(i, field){ $("#results").append(field.value + " ");}); 遍历每个控件值
共同学习,写下你的评论
评论加载中...
作者其他优质文章