Skip to content Skip to sidebar Skip to footer

Jquery Not Working In Dynamically Generated Form

I am generating a form in www.sitetwo.com by using some scripts called from www.siteone.com. As I have to submit the form in www.sitetwo.com to www.siteone.com, I am using Ajax usi

Solution 1:

You are generating the form dynamically, to apply some events to the dynamic element you have to use .on(), other thing is to change the event to mouseenter or mouseleave instead of hover

try this:

$(document).on('mouseenter', '.submitbutton', function(){
  alert("hai");
}

Solution 2:

You can't use hover in that case, need to use delegated event handlers using events mouseenter and mouseleave

.hover() is not a event, it is a helper method to register mouseenter and mouseleave event handlers

Bind two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements.

$(document).on('mouseenter', '.submitbutton', function(){
  alert("hai");
}

Solution 3:

$(".submitbutton").hover(function(){
      alert("hai");
    }

change in

$(".submitbutton").on("hover",function(){
      alert("hai");
    }

reference hover

Post a Comment for "Jquery Not Working In Dynamically Generated Form"