【问题标题】:How to unselect all elements which are Not input fields如何取消选择所有非输入字段的元素
【发布时间】:2011-11-16 02:15:27
【问题描述】:

我的页面上有很多大图像,当用户将光标拖到它们上面时,选中的蓝色突出显示会使图像变暗并且不会轻易消失。如何使用this plugin(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
        });
};

找到被选中的元素并取消选中它们,除了表单、文本区域和输入字段需要被选中才能起作用。

也许涉及@ 987654324 jQuery selector

非常感谢!

【问题讨论】:

    标签: jquery jquery-plugins select jquery-selectors


    【解决方案1】:

    :selected 选择器用于选择语句,即。列表/选项。

    您为什么不将适当的 CSS 添加到您不想选择的图像中? 如果您正在监听某些拖动事件,只需在拖动开始时将其应用于所有图像。

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

    【讨论】:

      猜你喜欢
      • 2014-06-04
      • 2020-04-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-19
      • 2018-11-05
      相关资源
      最近更新 更多