首页 > 学院 > 开发设计 > 正文

关于jquery

2019-11-17 02:06:41
字体:
来源:转载
供稿:网友
关于jquery

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="Test.test" %>

<!DOCTYPE html><html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <script type="text/javascript" src="jquery.js"></script> <script type="text/Javascript"> $(function () { $("#test").bind("click", function () { //select下拉 .text()表示填充文本;.val()表示获取选择元素的值 //var _select = $("select option:selected").text();// .val(); //var _select = $("input[name^='news']").val(); var _select = ""; $.each($("input[name^='news']"), function (i, n) { _select += $(n).val() + ","; }); if (_select.length > 0) _select = _select.substr(0,_select.length-1);

//$.each($("input[name^='news']"));// 正则表达式规则,所以^代表开始,$代表结尾 /^ $/ //$.each("input[name*='news']");//所有对象中包含news的元素

//lastindexof从0开始计数 /* var str = "Hello world!" document.writeln(str.lastIndexOf("Hello")); document.writeln(str.lastIndexOf("World")); document.write(str.lastIndexOf("world")); */

/*var _val = "我是测试,"; //var _val = _val.substr(0,_val.length-1);//从0开始 _val = _val.substring(0,2);//包括开始的位置,不包含结束的 alert(_val); */

/* var str1 = "我是测试是";//出现第一个“是”的位置, var s = str1.indexOf("是");//1 var s1 = str1.lastIndexOf("是");//4,最后一个“是” alert(s+", " + s1); */

//$("p").PRependTo("#foo");

//$("p").toggle();//切换隐藏/可见 //$("p").toggle(true);// <p>Hello</p><p style>Hello Again</p> 2个都显示

//$("#results").append("<tt>" + $("form").serialize() + "</tt>");

//判断是否为数组 var a = new Array(); a.push("张三"); a.push(1); alert($.isArray(a)); // true

var obj = {}; obj[0] = 10; obj[1] = 25; obj[2] = 3; obj.length = 3; // obj是一个类数组对象,但它仍然不是一个真正的数组 alert($.isArray(obj)); // false

});

});

</script></head><body> <div>

<p id="results"><b>Results:</b> </p><form> <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"/> check1 <input type="checkbox" name="check" value="check2" checked="checked"/> check2 <input type="radio" name="radio" value="radio1" checked="checked"/> radio1 <input type="radio" name="radio" value="radio2"/> radio2</form>

<!--<p>Hello</p><p style="display: none">Hello Again</p> <p>I would like to say: </p><div id="foo"></div> -->

<input name="newsletter" value="Flowers" style=" display:none;" /> <input name="milkman" value="2" style=" display:none;" /> <input name="newsboy" value="Trees" style=" display:none;" />

<select style="display:none;"> <option value="1">Flowers</option> <option value="2">Gardens</option> <option value="3">Trees</option> </select>

<button id="test" style=" width:70px; height:20px;">点击测试</button> </div> </body></html>


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表