標籤:ret 地址 doc err 修改 put case 選取器 文法
$("input[name=當前文字框的name]:checked").val()--擷取文字框的值
$("input[name=當前文字框的name]:input").val() --文字框取值
$("#文字框id").val() --- 擷取文字框值
JSON.stringify(obj) --將集合轉換成字元竄
var myObject=[{name: ‘dahuang‘ , id: 2 },{name:‘dahuang2‘,id:3},{name:‘dahuang3‘,id:4}] ----聲明一個 對象的集合
JSON.stringify(對象); //對象轉換字串
JSON.parse(字串); //字串轉對象
對象名["屬性名稱"] = 屬性值;// 對象中加一個屬性
$(obj).attr("屬性名稱", "屬性值");修改屬性值
----清空表單內容
($("#選取器"))[0].reset();
-----js中的replaceall------------------------------------------------------
str.replace(new RegExp(/(要轉內容)/g),‘想轉內容‘)
-----最常規的一個ajax-------------------------------------------------
$.ajax({
url: "./TestXHR.aspx", //請求地址
type: "POST", //請求方式
data: { name: "super", age: 20 }, //請求參數
dataType: "json",
success: function (response) {
// 此處放成功後執行的代碼
alert(1);
},
error: function (status) {
alert(2);
// 此處放失敗後執行的代碼
}
});
-----------------------------------------------
-------------------------------------------------
----兩個介面, 介面1擷取介面2的值 返回到ids中 (例子:CDCPro singlePage :jhbbldjglk.jsp和zzlist.jsp )
--介面1的function代碼
function myclick3()
{
var ids = window.showModalDialog(‘mytest1.jsp‘,null,‘dialogWidth=1000px;dialogHeight=1000px‘);
}
--介面2的function代碼
function test55(){
window.returnValue = "asdasda";
window.close();
}
----------------------------------------------------------
-----------------------------------------------------------
--- 擷取table 的第i行第j列的值
$(‘#mytable tr‘).each(function (i) {
var td[i]=$(this).children(‘td‘).eq(0).html(); //擷取table
}
});
-----------------------------頁面載入時 添加onchange事件
$(document).ready(function () {
$("#sTwo").combobox({
onChange: function (n,o) {
alert("我是老大!");
}
});
});
-----------------------
/* //遍曆td迴圈擷取報告卡編號
i=i+1;
var bgkbh="";
$(‘#mytable tr‘).each(function (t) {
if(i==t){
bgkbh=$(this).children(‘td‘).eq(0).html(); //擷取table
}
});
*/
------------------------js轉碼(中文----》亂碼)
var GB2312UnicodeConverter = {
ToUnicode: function (str) {
return escape(str).toLocaleLowerCase().replace(/%u/gi, ‘\\u‘);
}
, ToGB2312: function (str) {
return unescape(str.replace(/\\u/gi, ‘%u‘));
}
};
建立方法,直接調用 GB2312UnicodeConverter.ToUnicode(str);
-------亂碼轉回中文。decodeURI(str);
-------------遍曆test1 from中的所有input
$(‘#test1 input‘).each(function(){
alert(i);
i=i+1;
var name = this.name;
alert(name);
});
前端jquery一些基本文法