JQuery对基本Html控件的操作TextBox、Select、Radio、CheckBox .
来源:互联网 发布:聚宝盆软件下载 编辑:程序博客网 时间:2024/05/16 12:41
- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="ControlGetAndSet.aspx.cs" Inherits="JQueryExample_ControlGetAndSet" %>
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head runat="server">
- <title></title>
- <mce:script src="../JS/jquery-1.3.2.min.js" mce_src="JS/jquery-1.3.2.min.js" type="text/javascript"></mce:script>
- <mce:script type="text/javascript"><!--
- function GetText() {
- var text = $("input[name=text1]").val();
- alert(text);
- //用id获取 text的value值
- var tmp = $("#text1").val();
- alert(tmp);
- }
- function SetText() {
- var text = $("input[name='text1']");
- text.val("用Name获取赋值");
- //var tmp = $("#text1").val("用ID获取赋值");
- }
- //获取Select选中值
- function GetSelect() {
- var sel = $("select[name='select1']").text();
- //var sel = $("select[name='select1'] option[selected]").text();
- //通过id获取
- //var sel = $("#select1").text();
- alert(sel);
- }
- //设置选中项的值 未实现 只能设置已有项选中
- function SetSelect() {
- //$("#select1").val("北京");//将value为“北京”的项选中
- $("#select1 ").get(0).selectedIndex = 1
- }
- //添加Option
- function AddSelectOptions() {
- //$("<option>北京</option>").appendTo("#select1");
- //for(var i=0;i<5;i++)
- //{
- // $("<option>" + i + "</option>").appendTo("#select1");
- //}
- //prepend为第一个,append(appendTo)为追加
- $("#select1").append("<option>北京</option>");
- for(var i=0;i<5;i++)
- {
- $("#select1").append("<option>" + i + "</option>");
- }
- }
- //移除选中项
- function RemoveSelectOptions() {
- $("#select1 option[selected]").remove();
- }
- //清空option
- function ClearSelectOptions() {
- //$("#select1").empty();
- $("#select1").html("");
- }
- function GetCheck() {
- var check = $("#checkbox1").attr("checked");
- alert(check);
- }
- function SetCheck() {
- $("#checkbox1").attr("checked", true);
- }
- function AddCheck() {
- $("<input type='checkbox' />").appendTo("#form1");
- }
- function GetRadio() {
- var ra = $("input[type='radio'][checked]").attr("value");
- //var ra = $("input[type='radio'][checked]").val();
- alert(ra);
- }
- function SetRadio() {
- //$("input[type='radio']").get(0).checked = true;
- $("input[type='radio'][value=2]").attr("checked","checked");
- }
- // --></mce:script>
- </head>
- <body>
- <form id="form1" runat="server">
- <div>
- <input id="checkbox1" type="checkbox" value="是否正确" style="width:100px" />
- <input id="btnGetCheck" type="button" value="获取Check是否选中" onclick="GetCheck()" />
- <input id="btnSetCheck" type="button" value="设置Check选中" onclick="SetCheck()" />
- <input id="btnAddCheck" type="button" value="新增Check" onclick="AddCheck()" />
- </div>
- <div>
- <input id="radio1" type="radio" value="1" style="width:50px" />
- <input id="radio2" type="radio" value="2" style="width:50px" />
- <input id="btnGetRadio" type="button" value="获取Radio是否选中" onclick="GetRadio()" />
- <input id="btnSetRadio" type="button" value="设置Radio选中" onclick="SetRadio()" />
- </div>
- <div>
- <select id="select1" name="select1">
- <option>上海</option>
- </select>
- <input id="btnGetSelect" type="button" value="获取选中项值" onclick="GetSelect()" />
- <input id="btnSetSelect" type="button" value="设置选中项值" onclick="SetSelect()" />
- <input id="Button1" type="button" value="添加Option" onclick="AddSelectOptions()" />
- <input id="Button2" type="button" value="移除选中项" onclick="RemoveSelectOptions()" />
- <input id="Button3" type="button" value="清空下拉框" onclick="ClearSelectOptions()" />
- </div>
- <div>
- <input id="text1" name="text1" type="text" value="文本框" />
- <input id="btnGetText" type="button" value="获取Text值" onclick="GetText()" />
- <input id="btnSetText" type="button" value="设置Text值" onclick="SetText()" />
- </div>
- </form>
- </body>
- </html>
- JQuery对基本Html控件的操作TextBox、Select、Radio、CheckBox
- JQuery对基本Html控件的操作TextBox、Select、Radio、CheckBox .
- JQUERY对RADIO,CHECKBOX,SELECT的操作
- jquery对radio、checkbox、select的操作
- Jquery 操作Html 控件 CheckBox、Radio、Select 控件
- Jquery 操作Html 控件 CheckBox、Radio、Select 控件
- Jquery 操作Html 控件 CheckBox、Radio、Select 控件
- Jquery 操作Html 控件 CheckBox、Radio、Select 控件
- jquery操作select、checkbox、radio控件
- jQuery 操作 html 元素的例子 (input/select/checkbox/radio)
- jquery对text/radio/checkbox/select/areatext的操作
- jQuery对select、radio和checkbox的操作
- jQuery对select、radio和checkbox的操作 .
- jQuery对radio,checkbox,select元素的操作
- jquery下的 radio,checkbox,select操作
- Jquery对一些常用控件的取值、赋值<textbox,button,lable,radio,checkbox,selected >
- jquery radio,checkbox,select操作
- jquery radio,checkbox,select操作
- 解决socket.error: [Errno 98] Address already in use问题
- Java程序员从笨鸟到菜鸟之(一百零五)java操作office和pdf文件(三)利用jxl实现数据导出excel报表以及与POI的区别
- linux 根据端口号查找对应进程的ID,操作进程
- 初用Google SVN个人心得
- 双十一的成功未必是好事
- JQuery对基本Html控件的操作TextBox、Select、Radio、CheckBox .
- 趣谈 i++ ++i i-- --i
- 基于 OSGi 和 Spring 开发 Web 应用
- 线程同步--关键代码段(二)
- asp.net mvc源码分析-DefaultModelBinder 自定义的普通数据类型的绑定和验证
- windows ce6.0安装无Tools文件问题
- 精于硬件,臻于完美
- QML中state元素与transition的使用个人体会
- Excel Solver 优化求解。