87,909
社区成员
发帖
与我相关
我的任务
分享
$(function(){
alert("页面生效");
$(".login_shopcart").blur(function(){
alert("blur生效");
$(".shopcart_img").attr("src","myimg/shopcart_img.png");
$("#ShopCart_num").show();
});
$(".login_shopcart").focus(function(){
alert("focus生效");
$(".shopcart_img").attr("src","myimg/Login.png");
$("#ShopCart_num").hide();
});
});
$(document).click(function(){
$("#login_shopcart").click(function(){
return false;
});
$(".shopcart_img").attr("src","myimg/shopcart_img.png");
$("#ShopCart_num").show();
});
$(function () {
alert("页面生效");
$(".login_shopcart").hover(function () {
alert("blur生效");
$(".shopcart_img").attr("src", "myimg/shopcart_img.png");
$("#ShopCart_num").show();
}, function () {
alert("focus生效");
$(".shopcart_img").attr("src", "myimg/Login.png");
$("#ShopCart_num").hide();
});
});
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
$(function(){
alert("页面生效");
$(".login_shopcart").blur(function(){
alert("blur生效");
$(".shopcart_img").attr("src","myimg/shopcart_img.png");
$("#ShopCart_num").show();
});
$(".login_shopcart").focus(function(){
alert("focus生效");
$(".shopcart_img").attr("src","myimg/Login.png");
$("#ShopCart_num").hide();
});
$(document).ready(function(){
alert("document生效");
$(".login_shopcart").ready(function(){
});
});
});
</script>
</head>
<body>
<div class="login_shopcart" style="position:fixed;bottom:0px;right:100px;">
<p style="position: absolute;padding: 10px 0 0 40px;color:white;" id="ShopCart_num">0</p>
<img alt="#" src="myimg/ShopCart.png" class="shopcart_img">
</div>
</body>
</html>
完整代码如上