檔案下載:
Minified http://code.jquery.com/jquery-1.7.1.min.js
Uncompressed http://code.jquery.com/jquery-1.7.1.js
兩個版本是一樣的 Uncompressed 是把內容中的空格、換行拿掉,節省一點空間
使用方法:
<html>
<head>
<title>jQuery Tutorial 1</title>
<script type="text/javascript" src="jquery-1.7.1.js"></script><!--jquery 的路徑-->
<script type="text/javascript">
function showMsg() {// 取得 id 為 msg 的物件, 然後再物件裡放入 Hello
$('#btn').attr('disabled', true);
if ($('#msg').html().length == 0) {//jQuery 裡 html 函式若是沒有傳參數進去的話,它就會回傳該 DOM 元件下的 HTML 字串,所以若回傳的字串長度等於 0 的時候才塞 HTML 進去
$('#msg').html('<h1>Hello</h1>');
}
$('#msg').fadeIn();//淡入show()
setTimeout(function(){//使得字樣出現的 3000 毫秒(也就是 3 秒)後,用了 jQuery 的 hide 方法把字隱藏起來
$('#msg').fadeOut();//淡出hide()
$('#btn').attr('disabled', false);
}, 3000);
}
</script>
</head>
<body>
<div id="msg"></div>
<input type="button" value="Click Me" onclick="showMsg()" id="btn"/>
</body>
</html>
資料來源:http://blog.ericsk.org/archives/834
沒有留言:
張貼留言
注意:只有此網誌的成員可以留言。