press down one button, the rest automatically bounce up
what i want to do is exactly same like this
<!DOCTYPE html>
<html>
<head>
<style>
div1, div2
{
width: 60px;
height: 60px;
margin: 5px;
float: left;
background: green;
border: 10px outset;
cursor: pointer;
}
p
{
color: red;
margin: 0;
clear: left;
}
</style>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<div1></div1>
<div2></div2>
<p>
Click a green square...</p>
<script>
$("div1").click(function() {
$(this).css({ borderStyle: "inset",
cursor: "auto"
});
$("div2").css({ borderStyle: "outset",
cursor: "auto"
});
});
$("div2").click(function() {
$(this).css({ borderStyle: "inset",
cursor: "auto"
});
$("div1").css({ borderStyle: "outset",
cursor: "auto"
});
});
</script>
</body>
</html>
but now i want to make the code a bit more neat, so i was trying with this
<!DOCTYPE html>
<html>
<head>
<style>
div { width:60px; height:60px; margin:5px; float:left;
background:green; border:10px outset;
cursor:pointer; }
p { color:red; margin:0; clear:left; }
</style>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>
<div></div>
<div></div>
<p>Click a green square...</p>
<script>
$("div").click( function() {
$(this).css({ borderStyle: "inset",
cursor: "auto"
});
$('div:not(this)').css({ borderStyle: "outset",
cursor: "auto"
});
});
</script>
</body>
</html>
but unfortunately, have work it out yet, can anyone help me with it? thanks in advance