How to implement hover functionality using JQuery?
Through hover functionality behavior can be implemented to an element during the time when the mouse is within the element. It is very simple lines of code and can be used in many applications including MVC4.0
Description:
You have to put control on which you want to display hover and one label with label id so that # is used in jquery alongwith id for identification purpose.
Run the application and put your mouse over that control to check the result. When you leave your mouse from that control, label will be hide hence you will not get message.
If you want to display tool tip/hover by moving mouse over any particular control then you can use following code:
<script type="text/javascript">
$(document).ready(function () {
$('#controlid').mouseover(function () {
$('#labelid').show();
$('#labelid').append('<div>Hover is implemented successfully!</div>');
});
$('#controlid').mouseleave(function () {
$('#labelid').hide();
});
});
</script>
Everytime on success, message gets appended to control. This is mainly used when the user wants to use jQuery's various toggle methods within the handler depending up on the type of the event, it will respond.