javascript - How to stop incrementing a variable when drop in same dropspot -


I have 7 droppots and 7 dragable elements I can use the same element for all 7 dragpots or I I can use all the draggable elements on the same drawspot. I have an extreme contor which is an increase in the drop but, if I drag all the elements on the same dropopsot it reaches the variable 7 and something happens. I need to increment the drop-once per bar once for the variable, even if I change the drops and src 7 times in the same droppings. My code looks like this:

  drop: function (Event, UI) {dropTarget = event.target.id; IndexDrops = dropTarget.charAt (dropTarget.length-1); $ ("#dropSpot" + IndexDrop). CSS ("Opacity", 0); $ ("#droppot" + indexdrops). Children ("IMG"). Prop ('src', dragregras.rc); Interval = set interval (Shodrock, 1); $ (Object-tooth [indexdes]). CSS ('visibility', 'visible'); CONTOR ++; If (contor == 7) {resetBtn.disabled = false; $ (DragObjects) .draggable ("disabled"); UpdateBubble (2); }; }  

You really need to read in your code Many false things ...

1 - Do not select the group with the id:

To do the following: ObjectsToHide.push (document.getElementById ("tochange" + i));

Instead, use a class to select several elements.

  ObjectsToHide = $ ('.class');  

2 - Save no index:

  indexDrags = dragObjects.indexOf (event.currentTarget);  

Instead of reinventing the element in itself, so that you can choose it again.

  dragsEl = event.currentTarget;  

3 - Do not repeat questions:

  $ ("# dropspot" + indexDrops). Css ("Opacity", 0); $ ("#droppot" + indexdrops). Children ("IMG"). Prop ('src', dragregras.rc);  

Re-use or chain it by saving the query in a var.

  var q = $ ("# dropspot" + indexDrops). Css ("opacity", 0). Children ("IMG"). Props ('src', DragraGridge RC); 4 - If you need a single operation timer, use setTimeout Do not use Set Internal unless you want to perform the operation repeatedly.  

5 - When you make belts, you have to refer to your libraries. In your case: jquery and jquery UI

  • Read more

    6 - You need a full context of your images, or they will not be loaded:

     < Code> src = "images / clouds.svg"  

    instead

      src = "http://your.site/images/clouds.svg " 

    Comments

    Popular posts from this blog

    import - Python ImportError: No module named wmi -

    Editing Python Class in Shell and SQLAlchemy -

    c# - MySQL Parameterized Select Query joining tables issue -