0

The following code, from the Google-Caja playground,shows two boxes. And once you drag on inside the other the enclosing box changes color:

<style>
  #draggable { width: 100px; height: 100px; padding: 0.5em; float: left; margin: 10px 10px 10px 0; }
  #droppable { width: 150px; height: 150px; padding: 0.5em; float: left; margin: 10px; }
 <script>
  $(function() {
    $( "#draggable" ).draggable();
    $( "#droppable" ).droppable({
      drop: function( event, ui ) {
        $( this )
          .addClass( "ui-state-highlight" )
          .find( "p" )
            .html( "Dropped!" );
      }
    });
  });
  </script>
3
  • 1
    jQuery is written in JavaScript! YES! Commented Apr 27, 2012 at 16:12
  • 1
    "Is it possible to convert this JQuery code to JavaScript?" Of course. jQuery is a library built with JavaScript. There's nothing you can do with jQuery you can't do without it. I'm not saying I'd recommend it, though; jQuery (and other libraries) exist for a reason. ;-) Commented Apr 27, 2012 at 16:12
  • @Wiseguy - Yes, that's what I meant. But maybe it was a little naive of me? Thanks! Commented Apr 27, 2012 at 16:13

3 Answers 3

4

Yes it is with a bit of work. The find, addClass and html ones are easy but the drag and drop is another story. here is a tutorial for it http://luke.breuer.com/tutorial/javascript-drag-and-drop-tutorial.aspx

Sign up to request clarification or add additional context in comments.

Comments

1

Yes. You can convert absolutely any JavaScript library code to pure JS, since that's what they use after all.

Comments

1

It's possible, but the .draggable() and .droppable() functions are much too complicated to explain how to do it here. Look at the unminified jQuery UI. That will give you a good start (although it will still be using jQuery).

1 Comment

Thanks a lot! I'm looking up " unminified jQuery UI" right now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.