$(document).ready(function() {
$(".g-t").mouseover(function() {
$(this).addClass("gramericin")
$(".g-t").click( function () {
$(".grammar-box2").stop().animate({ width: 'show' });
$(".grammar-box2 #div1").load("http://stackoverflow.com/questions/40840852/difference-between-res-setheader-and-res-header-in-node-js");
});
});
$(".g-t").mouseout(function() {
$(this).removeClass("gramericin");
$(".grammar-box2").click(function() {
$(".grammar-box2 #div1").empty();
$(".grammar-box2").stop().animate({ width: 'hide' });
});
});
});
.grammar-box2 {
display: none;
width: 450px;
height: 520px;
position: absolute;
right: 0;
z-index: 10;
background-color: rgb(228, 255, 179);
color: black;
font-size: large;
font-weight: bolder;
padding: 10px;
}
.gramericin {
background-color: rgba(200, 0, 0, 0.5);
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="grammar-box2">
<div id="div1"></div>
</div>
<p class="g-t">something</p>
$(document).ready(function() {
$(".g-t").click( function () {
$(".grammar-box2").animate({ width: 'show' });
$(".grammar-box2 #div1").load("grammar.html #amisare");
});
});
$("#butonx").click(function() {
$(".grammar-box2 #amisare").empty();
$(".grammar-box2").animate({ width: 'hide' });
});
});
I tried .stop()
but it didn't work. If I animate the box a lot it starts lagging when it animates the box.
edit: when I remove load()
event the animate()
isn't lagging. But I must use load()
event to get some data.