vgrabovets
4/2/2017 - 7:07 PM

remove element on mouse hover

remove element on mouse hover

$("body").mousemove(
  
  function(event){

    function getCookie(name) {
      var value = "; " + document.cookie;
      var parts = value.split("; " + name + "=");
      if (parts.length == 2) return parts.pop().split(";").shift();
    }

    function setCookie(cname, cvalue, exdays) {
        var d = new Date();
        d.setTime(d.getTime() + (exdays*24*60*60*1000));
        var expires = "expires="+ d.toUTCString();
        var cookies = getCookie('block');
        if (cookies) {
          document.cookie = cname + "=" + cookies + ', ' + cvalue + ";" + expires + ";path=/";
        } else {
          document.cookie = cname + "=" + cvalue + ";" + expires + ";path=/";
        }
    }

    $(event.target).remove();
    elem = $(event.target).attr('src');
    console.log('Mouse Gestures removed ', $(event.target).attr('src'));
    $('body').unbind('mousemove');
    setCookie('block', elem, 1);
  }
)