Droppable 的值计数 (JQuery)
我正在为调查创建问题类型。
我正在使用下面的jsfiddle
我需要的是一个计数器或其他东西同样,这会让我知道有多少红色块被丢弃到底部灰色块上。
例如。非常同意 = 2(当 2 个红色掉落到其上时) 同意 = 1(当 1 个红色块落到其上时)等。
谢谢!
I am creating a question type for a survey.
I am using the below jsfiddle
What i need is a counter or something alike that will let me know how many of the red blocks are being dropped onto the bottom gray blocks.
eg. Strongly Agree = 2 (when 2 red are dropped onto it)
Agree = 1 (when 1 red block is dropped onto it) etc.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当你放下一个红色盒子时,你能得到灰色盒子的类吗?
我的想法是,您可以将灰色的类别添加到红色的类别中,然后简单地计算其类别中具有特定灰色的所有红色。
所以 class="red1" 和 drop class="red1 grey2" 后。
当您选择类别中有“灰色”的红色时,您需要删除灰色类别名称。
我知道我没有引用任何代码,但我只是在考虑概念而不是实际代码。如果你愿意的话我可以尝试一下。
所以我认为过程如下。
设置:
灰盒类
在放置时有额外的类,如 class="GreyBox Grey1" 和 class="GreyBox Grey2":
$('.Grey1').length
jQuery 获取灰色拾取时的
When you drop a red box, can you get the class of the grey box?
what i'm thinking is that you can add the class of the grey to the class of the red and then simply do a count of all reds with a particular grey in its class.
so class="red1" and after drop class="red1 grey2".
when you pick up a red that has "grey" in it's class, then you need to remove the grey class names.
i know i didn't reference any code but i was just thinking of the concept rather than actual code. I can have a go if you wish though.
so the process i think would be as follows.
setup:
Grey box class has extra class like class="GreyBox Grey1" and class="GreyBox Grey2"
on drop:
$('.Grey1').length
on pick up off grey