Probably, what you observe accurately describes the behavior of your code, but it would take to much time to analyze it. Instead, better modify your code, it's wrong. First of all, you have two scripts both handling
$(document).ready
. Do it only once, and in one script. Also, if you want to handle
.hover()
, no need to write
.mouseleave()
.
hover()
already expects two handler methods, first for mouse in, second one for mouse out. Please see:
http://api.jquery.com/hover/[
^].
Also, you should re-use the wrapper objects returned by
selectors. If you calculate
$("#btndiv")
if finds some HTML DOM object by its attribute
id="btndiv"
and returns you a jQuerty wrapper for this element, you don't need to calculate it again and again — it takes considerable time and simply is not supportable (what if you change the id? going to change it in 3 other places?!).
It should be something like:
$(document).ready(function () {
firstDiv = $("#btndiv1");
secondDiv = $("#btndiv");
firstDiv.hover(
function () {
},
function () {
}
);
});
Read more carefully:
http://docs.jquery.com/How_jQuery_Works[
^],
http://api.jquery.com/category/selectors/[
^].
Good luck,
—SA