skip to Main Content

Is it possible to cleanly combine this function.
I am using mouseenter function to show my ajax page content and hide it with mouseleave

$(function() {
    $("#card_client").mouseenter(function(){
        $("#results").load("data/show_card.php");
        $("#results").show();
    });

     $("#card_client").mouseleave(function(){
        $("#results").hide();
    });
});

2

Answers


  1. Chosen as BEST ANSWER

    Now when I hover over the data displayed by "#results" the display flashes. I would like it to stay fixed

        $( "#tablesForm tr" ).hover(
      function() {
          var idCard = $(this).attr("id");
          if (idCard > 0) {
         $("#results").load("data/show_card.php?mode=client&id="+idCard).show();
          }
      }, function() {
         $("#results").hide();
      }
    );
    

  2. Use .hover() to combine them into one call:

    $(function() {
        $("#card_client").hover(function(){
            $("#results").load("data/show_card.php").show();
        }), function(){
            $("#results").hide();
        });
    });
    

    The first function is executed when you start hovering, the second when you stop.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search