开发者

How to unselect all elements which are Not input fields

开发者 https://www.devze.com 2023-04-05 01:02 出处:网络
I have alot of large images on the page and when the user drags the cursor over them the blue selected highlight overcasts the images and won\'t easi开发者_运维技巧ly go away. How can I use this plugi

I have alot of large images on the page and when the user drags the cursor over them the blue selected highlight overcasts the images and won't easi开发者_运维技巧ly go away. How can I use this plugin (the noSelect jQuery-Plugin)

$.fn.noSelect = function(){
        var none = 'none';
        return this.bind('selectstart dragstart mousedown', function() {
                return false;
        }).css({
                'MozUserSelect': none,
                'WebkitUserSelect': none,
                'userSelect': none
        });
};

and find the elements which are selected and unselect them, all except forms, textareas, and input fields which need to be selected in order to function.

Maybe something involving the :selected jQuery selector?

Thank you so much!


The :selected selector is used for select statements, ie. lists/options.

Why don't you just add the appropriate CSS to the images you don't want selected? If there is some drag event you're listening for, just apply it to all images upon drag start.

var isDragging = false;
$(document).ready(function(){
        $("img").noSelect();
        //or
        $(document).mousedown(function(){
             isDragging = true;
             $("img").noSelect();
        }).mouseup(function(){
             isDragging = false;
             $("img").makeSelectable();
        });
});
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号