Jquery可选择无需控制 [英] Jquery Selectable without holding control

查看:77
本文介绍了Jquery可选择无需控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 Jquery Selectable 但是用户必须按住控制按钮才能选择项目无论如何,用户可以选择多个项目而无需按住控制按钮?

I use the Jquery Selectable But the user have to hold the control button down to select items is there anyway that user can select multiple items without holding control button down ?

换句话说:我希望用户能够通过单击选择任何项目并取消选择它再次点击。

in other words: I want the user to be able to Select any item by clicking on it and Unselect it by Clicking again.

推荐答案

您可以在用户点击元素时添加已选择类,只需删除该类再次点击时。

You can add the class "selected" when the user clicks the elements, and simply remove the class when clicked again.

$(".selectable").click(function(e) {
    $(this).toggleClass("selected");
});

这篇关于Jquery可选择无需控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆