1.獲取焦點選中文本內容
$("#id").focus(function(){
this.select();
});
2.表單提交方式
A.自動提交
setTimeout(function(){表單對象.submit();},2000);
B.onclick事件提交(鏈接提交)
- <input type="submit" value="提交" οnclick="return check()" />//check()為驗證方法
- <input type="button" value="提交" οnclick="Xxx()" />//function Xxx(){表單對象.submit();}
- <a href="javascript:表單對象.submit();" >提交</a>
C.form標簽上,onsubmit方式提交
οnsubmit="return check();//check()為驗證方法
3.json_encode和json_decode
json_decode($data) 把json串轉換成php變量(對象)
json_decode($data,true) 把json串轉換成關聯數組
json_encode($data) 把php變量轉換成json串
注意:json只接受utf-8編碼的字符,所以json_encode()的參數必須是utf-8編碼,否則會得到空字符或者null。