-1

I'm currently making an interactive game based around science. One of my interactive parts contains a list of draggable elements, I am trying to make it so when two of these elements are dragged onto a target they display the correct answer. For example Copper + sulphur = Copper sulphate. Any help would be greatly appreciated.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • I would suggest you start by reviewing the "Draggable" interaction on the jQuery website: https://jqueryui.com/draggable/. You should also be able to find examples that use these interactions elsewhere on this site. – Mike Zavarello May 12 '16 at 11:56
  • Thankyou, ill try that :) – Kyle Lumb May 12 '16 at 12:01
  • I've just had a look on the website and i am still unsure as to how i could make it so 2 objects have to be in the box to get the text to appear other than just one, thanks – Kyle Lumb May 12 '16 at 12:04

1 Answers1

0

Take a look at this question: jQuery UI dragging, update target element. What the person wanted to know about here is how to trigger an event whenever you drag an item over a target.

What you may wish to consider is something where dragging an element over the target adds the value to a JavaScript/jQuery variable or array. When the user drags the second element over the target, it adds/appends that new value onto the first variable/array you already set. If the combined value matches the correct answer, show the user it is correct. If not, let them know that's not the right answer and reset the values.

Here are some other StackOverflow questions that may be useful to you in researching and developing this solution:

Community
  • 1
  • 1
Mike Zavarello
  • 3,514
  • 4
  • 29
  • 43