課程
/前端開發
/jQuery
/jQuery基礎(三)—事件篇
把代碼貼到dw里運行,網頁上沒效果,是哪的問題
2017-06-07
源自:jQuery基礎(三)—事件篇 7-1
正在回答
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>JQ-test</title>
<style>
div { width: 500px; height: 200px; border: 1px solid green; margin: 0 auto; }
</style>
</head>
<body>
<div id="test">
<label></label><input type="text">
<input type="button" value="button1">
<input type="button" value="button2">
</div>
<!-- JS -->
<script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
<script type="text/javascript">
$('#test input:eq(1)').on('click',function(event,title){
if(!title){title = 'button1'}
updata(title)
})
$('#test input:eq(2)').click(function(){
$('#test input:eq(1)').trigger('click','button2')
function updata(title){
$('#test label:first').text(title);
var $text = $('#test input:first');
if(!$text.val()){ $text.val(0) }
$text.val(parseInt($text.val())+1)
}
</script>
</body>
</html>
用我寫的。
qq_細雨聽荷_0 提問者
舉報
jQuery第三階段開啟事件修煉,掌握對頁面進行交互的操作
4 回答這節課為什么里面的代碼沒反應.......
4 回答keypress和keydown運行起來效果一樣
4 回答這樣為啥沒效果?
1 回答這個有錯嗎,為什么我輸出沒效果
3 回答寫的東西是按照答案給的,為什么沒效果?
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網安備11010802030151號
購課補貼聯系客服咨詢優惠詳情
慕課網APP您的移動學習伙伴
掃描二維碼關注慕課網微信公眾號
2017-06-07
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>JQ-test</title>
<style>
div { width: 500px; height: 200px; border: 1px solid green; margin: 0 auto; }
</style>
</head>
<body>
<div id="test">
<label></label><input type="text">
<input type="button" value="button1">
<input type="button" value="button2">
</div>
<!-- JS -->
<script src="http://libs.baidu.com/jquery/1.9.1/jquery.js"></script>
<script type="text/javascript">
$('#test input:eq(1)').on('click',function(event,title){
if(!title){title = 'button1'}
updata(title)
})
$('#test input:eq(2)').click(function(){
$('#test input:eq(1)').trigger('click','button2')
})
function updata(title){
$('#test label:first').text(title);
var $text = $('#test input:first');
if(!$text.val()){ $text.val(0) }
$text.val(parseInt($text.val())+1)
}
</script>
</body>
</html>
用我寫的。