jQuery隨堂筆記

來源:互聯網
上載者:User

標籤:script   定義   鍵盤   string   nan   public   http   onload   tor   

一、彈出框
a.提示框
alert();
b.輸入框
prompt();
c.確認框
confirm();
var flag= confirm("確認刪除嗎?");
二、js程式調試
先看console控制台是否報錯
瀏覽器debug
alert();
console.log();
三、函數
系統函數:
parseInt(); 能夠轉換首字元是數位字串
Number();只能轉換數位字串
isNaN(); is not a number //是不是非數字?
自訂函數:
a、funtion 方法名(參數1,參數2...){
// return
}
funtion show(str,age){}
public void show(String str,int age){

}
b. var 方法名=function(參數1,參數2...){
//return 值
}
在超連結中調用js代碼
<a href="javascript:sf();">請點擊</a>
四、js中常用的事件
onload //頁面載入完畢執行
onclick //按一下滑鼠事件
onmouseover //滑鼠移上事件
onmouseout //滑鼠移開事件
onfocus //聚焦輸入框事件
onblur //移開輸入框事件
onkeydown; //鍵盤按下事件
斷行符號事件:
document.onkeydown=function(e){
if(e.keyCode==13){ //斷行符號鍵
alert("登入!");
}
}
onchange;//下拉框切換事件
<select onchange="alert(‘下拉框改變了‘);">
<option>北京</option>
<option>深圳</option>
<option>合肥</option>
</select>
onsubmit;//表單提交事件
五、瀏覽器物件模型
window對象(一般省略不寫)
window.onload = function(){
}
常用的屬性
history
window.history.go(-1);//返回上一個頁面
history.go(0);//重新整理
window.history.go(1);//下一個頁面
location
location.reload();//重新整理
跳轉頁面:
window.location.href = "http://www.bdqn.cn";
常用方法:
alert();prompt();confirm();
開啟新視窗 open();
關閉:close();

jQuery隨堂筆記

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.