Home > Enterprise >  jQuery function based on area of an image
jQuery function based on area of an image

Time:04-02

I would like to feed a cat with burgers. If you grab a burger and bring it to the cat's mouth, the burger should disappear.

Currently it looks like that:

$(function() {
  $(".burger").draggable();
});

$(".burger").on("click touchend", function() {
  $(this).css("display", "none");
});
* {
  font-size: 50px;
}

img {
  width: 200px;
}

.burger {
  cursor: grab;
  display: inline-block;
}
<script src="https://code.jquery.com/jquery-3.6.0.js"></script>
<script src="https://code.jquery.com/ui/1.13.1/jquery-ui.js"></script>

<img src="https://upload.wikimedia.org/wikipedia/commons/f/f8/Manul_kitten.jpg">

<div >           
  • Related