<%@ 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); */
新聞熱點
疑難解答