javascript - jquery draggable and changing the color of the background container -


i'm getting syntax error because doing wrong.

here code:

 <style>     body{margin:0 auto;}     .draggable { width: 100px; height: 100px; padding: 0.5em;background-color:red;}           </style>     <script>     $(function() {         $( ".draggable" ).draggable();     });     var i=0;     $(".draggable").each(function(i){      if(i%2==0){         #container("background-color:green");        }        i++;        });     </script>  </head> <body>  <div id="container" style="width:100%;height:400px;background-      color:#ccc;position:relative;"> <div class="draggable" class="ui-widget-content" style="margin-top:10%;margin-    left:1%;position:absolute;">     <p>drag me around</p> </div> <div class="draggable" class="ui-widget-content" style="margin-top:10%;margin-    left:20%;position:absolute;">     <p>drag me around</p> </div> <div class="draggable" class="ui-widget-content"style="margin-top:10%;margin-    left:33%;position:absolute;" >     <p>drag me around</p> </div> <div class="draggable" class="ui-widget-content"style="margin-top:10%;margin-    left:45%;position:absolute;" >     <p>drag me around</p> </div> <div class="draggable" class="ui-widget-content"style="margin-top:10%;margin-    left:60%;position:absolute;" >     <p>drag me around</p> </div> <div class="draggable" class="ui-widget-content" style="margin-top:10%;margin-    left:80%;position:absolute;">     <p>drag me around</p> </div> </div> 

in web developer tool syntax error here:

#container("background-color:green");

what need when draggable div moved out of container, if number of draggable divs remaining in container odd, background color of container turns green.

regards, umbre gachoong

replace

#container("background-color:green"); 

with

$("#container").css("background-color", "green"); 

Comments

Popular posts from this blog

java - Intellij Synchronizing output directories .. -

git - Initial Commit: "fatal: could not create leading directories of ..." -