Javascript-форум (https://javascript.ru/forum/)
-   jQuery (https://javascript.ru/forum/jquery/)
-   -   Почему событие (.hover) происходит один раз, а функция выполняется два раза? (https://javascript.ru/forum/jquery/14290-pochemu-sobytie-hover-proiskhodit-odin-raz-funkciya-vypolnyaetsya-dva-raza.html)

majahead 10.01.2011 12:04

Почему событие (.hover) происходит один раз, а функция выполняется два раза?
 
:blink:

<!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 src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js" type="text/javascript"></script>
<script>
jQuery(document).ready(function(){
		jQuery('.shot').hover( function(){ alert('hkj');});
})
</script>
</head>
<body>
<div class="shot" style="width:100px; height:30px; background:#CCC;"></div>
</body>
</html>

Gvozd 10.01.2011 12:10

http://api.jquery.com/hover/
вы испльзуете вариант
Цитата:

.hover( handlerInOut(eventObject) )
как результат, функция срабатывает когда мышка оказывается внутриЮ сперва, а затем, когда вы двигаете ее чтобы закрыть alert, после этого она оказывается снаружи, и снова вызывает событие


Часовой пояс GMT +3, время: 17:04.