Si8
Si8

Reputation: 9225

How to display an image when hover and clicked on the respective div

CSS:

.imgECheck {
    position: absolute;
    top: 0;
    right: 5px;
    width: 15px;
    height: 15px;
    display: none;
}
.imgFCheck {
    position: absolute;
    top: 0;
    right: 5px;
    width: 15px;
    height: 15px;
    display: none;
}

How can I achieve the function in the JQuery above.

Upvotes: 0

Views: 45

Answers (3)

AK47
AK47

Reputation: 71

Can you try bellow code

 $(function () {
    $('.imgFCheck').hide();

  $(document).on('click','.btn-small', function () {

    $(this).find('.imgFCheck').show().toggleClass('is-clicked');

  });

  $(document).on('hover','.btn-small', function () {
     if(!$(this).find('.imgFCheck').hasClass('is-clicked'))
      {
        $(this).find('.imgFCheck').toggle();
       }
   });

});

Upvotes: 1

Cruiser
Cruiser

Reputation: 1616

EDIT:

So after more info here's what I think you need:

$(".btn-small").on("hover", function(){
    $(".imgECheck").addClass("show");
});


$(".btn-small").click(function(){
    $(".imgECheck").removeClass("show");
    $(".imgFCheck").addClass("show");
});

Upvotes: 1

KAD
KAD

Reputation: 11102

$(function () {
    $(".btn-small").on("click", function () {
       $('.imgFCheck').hide();
       $(this).find('.imgFCheck').show();
    });
});

Upvotes: 1

Related Questions