JSFiddle - React, Tailwind, and code Playground

by lottikarotti

HTML

<html>
    <head>
        <script type="text/javascript" langueage="javascript">
            $(document).ready(function() {
                $('#test').close( ) ;
            }
        </script>
    </head>
    
    <body>
        <div id="test"></div>
    </body>

</html>

JavaScript

(function($) {
$.fn.close = function() {
return this.each(function(){
var sCloseImage = '<img class="close" src="http://www.okm-jena.de/images/CI/icons/close.gif" alt="close" />';
$(this).append(sCloseImage);
$(this).hover(function(){
var offset = $(this).offset();
var iWidth = $(this).outerWidth();
var sTop = offset.top + 5 ;
var sLeft = offset.left + iWidth - 30;
$(".close",this).show().offset({top: sTop , left: sLeft}).click(function(){
$(this).parent().remove();
});
},function(){
$(".close",this).last().hide();
});
});
};
})(jQuery);