初学jquery,看例子写了一段,可是效果出不来,为什么呢?
<!DOCTYPEhtmlPUBLIC"-//W3C//DTDHTML4.01Transitional//EN""http://www.w3.org/TR/html4/l...
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Hello World jQuery!</title>
<script type="text/javascript" src="../jquery/jquery-1[1].3.2.min.js"></script>
</head>
<body>
<div id="divMsg">Hello World!</div>
<input id="btnShow" type="button" value="显示" />
<input id="btnHide" type="button" value="隐藏" /><br />
<input id="btnChange" type="button" value="修改内容为 Hello World, too!" />
<script type="text/javascript" >
("#btnShow").bind("click", function(event) { ("#divMsg").show(); });
("#btnHide").bind("click", function(event) { ("#divMsg").hide(); });
("#btnChange").bind("click",function(event){ ("#divMsg").html("Hello World, too!"); });
</script>
</body>
</html> 展开
<html>
<head>
<title>Hello World jQuery!</title>
<script type="text/javascript" src="../jquery/jquery-1[1].3.2.min.js"></script>
</head>
<body>
<div id="divMsg">Hello World!</div>
<input id="btnShow" type="button" value="显示" />
<input id="btnHide" type="button" value="隐藏" /><br />
<input id="btnChange" type="button" value="修改内容为 Hello World, too!" />
<script type="text/javascript" >
("#btnShow").bind("click", function(event) { ("#divMsg").show(); });
("#btnHide").bind("click", function(event) { ("#divMsg").hide(); });
("#btnChange").bind("click",function(event){ ("#divMsg").html("Hello World, too!"); });
</script>
</body>
</html> 展开
4个回答
展开全部
<script type="text/javascript" >
$(document).ready(function(){
$("#btnShow").click(function(){
$("#divMsg").show();
});
$("#btnHide").click(function(){
$("#divMsg").hide();
});
$("#btnChange").click(function(){
$("#divMsg").html("Hello World, too!");
});
})
</script>
不需要用bind()绑定的
$(document).ready(function(){
$("#btnShow").click(function(){
$("#divMsg").show();
});
$("#btnHide").click(function(){
$("#divMsg").hide();
});
$("#btnChange").click(function(){
$("#divMsg").html("Hello World, too!");
});
})
</script>
不需要用bind()绑定的
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Hello World jQuery!</title>
<script type="text/javascript" src="../jquery/jquery-1[1].3.2.min.js"></script>
</head>
<body>
<div id="divMsg">Hello World!</div>
<input id="btnShow" type="button" value="显示" />
<input id="btnHide" type="button" value="隐藏" /><br />
<input id="btnChange" type="button" value="修改内容为 Hello World, too!" />
<script type="text/javascript" >
("#btnShow").bind("click", function(event) { $("#divMsg").show(); });
("#btnHide").bind("click", function(event) { $("#divMsg").hide(); });
("#btnChange").bind("click",function(event){ $("#divMsg").html("Hello World, too!"); });
</script>
</body>
</html>
这样就ok了
<html>
<head>
<title>Hello World jQuery!</title>
<script type="text/javascript" src="../jquery/jquery-1[1].3.2.min.js"></script>
</head>
<body>
<div id="divMsg">Hello World!</div>
<input id="btnShow" type="button" value="显示" />
<input id="btnHide" type="button" value="隐藏" /><br />
<input id="btnChange" type="button" value="修改内容为 Hello World, too!" />
<script type="text/javascript" >
("#btnShow").bind("click", function(event) { $("#divMsg").show(); });
("#btnHide").bind("click", function(event) { $("#divMsg").hide(); });
("#btnChange").bind("click",function(event){ $("#divMsg").html("Hello World, too!"); });
</script>
</body>
</html>
这样就ok了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
<script type="text/javascript" >
("#btnShow").bind("click", function(event) { ("#divMsg").show(); });
("#btnHide").bind("click", function(event) { ("#divMsg").hide(); });
("#btnChange").bind("click",function(event){ ("#divMsg").html("Hello World, too!"); });
</script>
应该这样:
<script type="text/javascript" >
$(function(){
("#btnShow").bind("click", function(event) { ("#divMsg").show(); });
("#btnHide").bind("click", function(event) { ("#divMsg").hide(); });
("#btnChange").bind("click",function(event){ ("#divMsg").html("Hello World, too!");});
});
</script>
("#btnShow").bind("click", function(event) { ("#divMsg").show(); });
("#btnHide").bind("click", function(event) { ("#divMsg").hide(); });
("#btnChange").bind("click",function(event){ ("#divMsg").html("Hello World, too!"); });
</script>
应该这样:
<script type="text/javascript" >
$(function(){
("#btnShow").bind("click", function(event) { ("#divMsg").show(); });
("#btnHide").bind("click", function(event) { ("#divMsg").hide(); });
("#btnChange").bind("click",function(event){ ("#divMsg").html("Hello World, too!");});
});
</script>
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询