0

I am working with jquery validation which is when press the submit button show error icon after hover the error icon message will display in tooltip. validation working fine with error icon now I want tool tip

$('#myForm').validate({
    rules:{firstname:"required"},
    messages:{firstname:"<div class='fir' style='display:none'>Please  enter your firstname</div>"
    }
});

I am trying to calling hover function it is not working

$('.error').hover(function(){
        alert("hello");
    });
2
  • "Not working" is never a sufficient problem description. Commented Dec 1, 2013 at 5:37
  • try using on() and mouseover together mate.. :) Commented Dec 1, 2013 at 5:42

4 Answers 4

1

Since the elements are created by the validation framework, they are dynamic so you need to make use of event delegation

$(document).on("mouseenter", ".error", function () {
    //stuff to do on mouseover
})
Sign up to request clarification or add additional context in comments.

4 Comments

$(document).on("mouseenter", "label .error", function () { $('.fir').show(); }); why it is not working
I think it should be $(document).on("mouseenter", "label.error", function () { $('.fir').show(); });, no space between label and .error
@downvoter did you downvote me and the upvote all the wrong answers below!!! I didn't downvote them anyway... common man.... don't be that idiot
arun i have one problem in validation when i press sumbit button error icon display after input filed .but in the case of onkeyup the error icon display in next line starting i want after input filed
0

You have the wrong function, try this:

$('.error').mouseover(function(){
                alert("hello");
            });

2 Comments

Thanks for help but i am sorry to say that it is not working i tried mouseover and mouseenter,hover funtion is not calling
Yeah, but this is the correct function that I've used a lot of time. So now you need to check your class .error(displaying) or make sure you have this class in your element class="error" for example.
0

Try this mate.Hope this might help u .. :)

$(".error").on("mouseover", function () {
    //stuff to do on mouseover
});

Comments

0

try this (put your code in document ready function...

$(document).ready(function(){

$('.error').mouseover(function(){
                alert("hello");
            });           
 });

REFERENCE MOUSEOVER

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.