我有一組div,我會在點擊時顯示,然後用右上角的「X」img關閉。我的問題是點擊div內的任何位置會導致它關閉,而不僅僅是右上角的X。我還想讓「X」成爲一個鏈接,因此當它懸停在光標變化上時。代碼如下,謝謝!div上的關閉按鈕無法正常工作
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<style type="text/css">
.county{
color:blue;
display:block;
}
.countystats{
background-image:url('../defunkt-facebox-cbe32e1/examples/closelabel.png') ;
background-position:top right;
border:3px black inset;
background-repeat:no-repeat;
background-color:#ccc;
display:none;
right:250px;
margin: 5px 5px 5px 5px;
padding:5px 5px 5px 5px;
width:200px;
}
</style>
</head>
<body>
<div style="height:250px;bottom:300px; width:100px; padding: 1em; overflow:auto; margin:5px 5px 5px 5px; border: 2px black; overflow-x:hidden;">
<a class="county" href="#">one</a>
<a class="county" href="#">two</a>
<a class="county" href="#">three</a>
<a class="county" href="#">four </a>
<a class="county" href="#">five</a>
<a class="county" href="#">six</a>
</div>
<div class="countystats">stats one<input maxlength="20" size="14" type="password"/><br/><p>woot</p></div>
<div class="countystats">stats two</div>
<div class="countystats">stats three</div>
<div class="countystats">some other stuff</div>
<div class="countystats">even more other stuff</div>
<br />
<br />
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript">
$('a.county').each(function(e){
$(this).bind('click', function(e){
var thisIs = $(this).index(); $('.countystats').eq(thisIs).show (250);
});
$("img").hide();
$(".countystats").click(function() {
$(this).hide(250);
return true;});
});
</script>
</body>
</html>
你有沒有X的任何一個角落.... – Neal 2011-03-31 20:21:44
在countystats上課有背景圖片。 closelabel.png是我正在談論的X.對不起! – closethemdangdivsright 2011-03-31 20:23:53