Getting the id element when click
Getting the id element when click using jquery
by hungqh87
HTML
<div id=boxes>
<div id=box1>box1</div>
<div id=box2>box2</div>
<div id=box3>box3</div>
<div id=box4><span class="childbox">Box4</span></div>
</div>
CSS
#boxes{
width: 200px;
height: 350px;
}
#box1{
width: 40px;
height: 35px;
background-color: red;
}
#box2{
width: 40px;
height: 35px;
background-color: yellow;
}
#box3{
width: 40px;
height: 35px;
background-color: blue;
}
#box4{
width: 60px;
height: 35px;
padding: 5px 10px 5px 10px;
background-color: green;
}
.childbox{
background-color: yellow;
padding: 2px;
}
JavaScript
$("#box2").hover( function(){
$(this).stop().html("BIGBOX").css("width", "70px");
}, function() {
$(this).stop().html("box2").css("width", "40px");
});