tags:

views:

224

answers:

3

I have document.ready function for image hover.

When the image id sign_up_close is there in the document the hover is working. If the same id is coming from the AJAX request then the hover is not working in JQuery.

Please give a solution, I have so many functions like this to be worked on AJAX request. The AJAX request is coming with the image with the id sign_up_close.

$(document).ready(function(){
 $("img#sign_up_close").hover(function(){
  $("img#sign_up_close").attr("src","images/buttons/btn_type1_23_close_pp_icon_.gif");
 },function(){
  $("img#sign_up_close").attr("src","images/buttons/btn_type1_23_close_pp_icon.gif");
 });
});
A: 

The Exact Question what Roopesh trying to ask is can we call the jquery using ajax or implementation of jquery in ajax.

A: 

Thanks Paolo Bergantino.

You suggested me exactly what I need. I got the solution.

Thanks roopesh

+1  A: 

If Paolo Bergantino is correct, another viable alternative is to use Jquery's LiveQuery.

Documentation can be found at http://docs.jquery.com/Plugins/livequery

Your code would probably look something like this:

$(document).ready(function(){
        $("img#sign_up_close").livequery(function() {
            $(this).hover(function() {
                $("img#sign_up_close").attr("src","images/buttons/btn_type1_23_close_pp_icon_.gif");
            }, function() { 
                $("img#sign_up_close").attr("src","images/buttons/btn_type1_23_close_pp_icon.gif");
            });
        });
});
spelley
Thankyou for this solution, it was applicable to my work.
Dave Kiss