Skip to content

jcubic/jquery.draglessClick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

jquery.draglessClick

Better jQuery click event that's not invoked when you drag or select text

npm bower

Usage:

$(function() {
    $('p').on('draglessClick', function handler(e) {
        // e is real click event from browser
        alert("You've really clicked this item");
        $(this).off('draglessClick', handler);
    });
    $('.container').on('draglessClick', 'ul li', function() {
       alert("You've clicked on li element");
    });
});

draglessClick event use mousedown, mouseup and click events added to element and mousemove added to windows object.

NOTE: names of the events in jQuery are case sensitive so draglessclick will not work.

Demo

https://codepen.io/jcubic/pen/QZxRLd

License

Released under MIT license

Copyright (c) 2018 Jakub T. Jankiewicz

About

Better jQuery click event that's not invoked when you drag or select text

Resources

License

Stars

Watchers

Forks

Packages

No packages published