我在页面上有很多大图像,当用户将光标拖到它们上面时,蓝色选中的高光会覆盖图像并且不会轻易消失。我如何使用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
});
};
找到被选中和取消选择的元素,除了表格,文本和输入字段之外的所有元素都需要选择才能运行。
可能涉及:selected
jQuery selector?
非常感谢你!
答案 0 :(得分:0)
:selected
选择器用于select语句,即。列表/选项。
为什么不将相应的CSS添加到您不想选择的图像中? 如果您正在侦听某些拖动事件,只需在拖动开始时将其应用于所有图像。
var isDragging = false;
$(document).ready(function(){
$("img").noSelect();
//or
$(document).mousedown(function(){
isDragging = true;
$("img").noSelect();
}).mouseup(function(){
isDragging = false;
$("img").makeSelectable();
});
});