Jump to content
  • 0

Onmouseout При Зажатой Лкм


graf
 Share

Question

Хочу чтобы при зажатии кнопки мыши изменялся стиль блока, а при отпускании возвращался обратно.

Казалось бы все просто onMouseDown и onMouseUp. Но если зажать лкм и уйти с блока, то возвращения к прежнему состоянию не происходит, и onMouseOut не работает.

Как сделать чтобы событие onMouseOut отрабатывало даже для зажатой лкм?

P.S. *лкм - левая кнопка мыши.

Вот мой код.


<script type="text/javascript">
function changebutton(id, state)
{

var obj=document.getElementById(id).style;
if (state == 'down') obj.background = "url('/img/button_pressed.png')";
if (state == 'up') obj.background = "url('/img/button_passive.png')";
if (state == 'out') obj.background = "url('/img/button_passive.png')";
}
</script>

<div class="photobutton" onMouseDown="changebutton('buttonleft', 'down');"
onMouseUp="changebutton('buttonleft', 'up');" onMouseOut="('buttonleft', 'out');" id="buttonleft"></div>

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. See more about our Guidelines and Privacy Policy