如:
<asp:TextBox ID="txtSubject" runat="server">aa</asp:TextBox>
<asp:TextBox ID="txtKeyWords" runat="server">bb</asp:TextBox>
<asp:TextBox ID="txtSummary" runat="server">cc</asp:TextBox>
......
我有多个以上的文本框,想实现的功能是:用JQuery一次性取到所有文本框的值,然后清空。
JQuery语句怎么写?跪求各位大虾帮忙...
------解决方案--------------------------------------------------------
- JScript code
$("input[type='text']").val("");
------解决方案--------------------------------------------------------
- HTML code
<html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <script type="text/javascript" src="script/Jquery.js"></script> <script type="text/javascript"> $(function () { var str=""; $("input[type=button]").click(function () { $("input[type=text]").each(function (i) { str += $(this).val(); }) alert(str); }) }) </script></head><body> <form id="form1" runat="server"> <asp:TextBox ID="TextBox1" runat="server">sdf</asp:TextBox> <asp:TextBox ID="TextBox2" runat="server">sdf</asp:TextBox> <asp:TextBox ID="TextBox3" runat="server">ee</asp:TextBox> <asp:TextBox ID="TextBox4" runat="server">ee</asp:TextBox> <asp:TextBox ID="TextBox5" runat="server">ee</asp:TextBox> <input type="button" name="button" value="button"/> </form></body></html>