javascript - Link piece to square in puzzle -


i making puzzle jquery , use draggable , droppable. yesterday made squares drop puzzle pieces in , i've tried link piece square making id same or class doesn't works.

does know how can link them if want drop piece on square square accept right piece?

i have 25 pieces , 25 squares drop in, 5x5.

    $(document).ready(function() {     $("button").button({icons: {         primary: "ui-icon-gear"     }});     $("img").draggable()            });        $(function() {    $( "#droppable" ).droppable({     drop: function( event, ui ) {     $( )       .addclass( "ui-state-highlight" )       .find( "img" ) ;             } }); }); 

html

<img id="puz1.1.1" class="puz1.1" src="images/1.1.1.png"/> <img class="puz1.1" src="images/1.1.2.png"/> <img class="puz1.1" src="images/1.1.3.png"/> <img class="puz1.1" src="images/1.1.4.png"/> <img class="puz1.1" src="images/1.1.5.png"/>        <div id="droppable" data="puz1.1a" class="ui-widget-header">   </div>   <div id="container">         <div id="kader">             <table border="0">                 <tbody>                     <tr>  <td id="puzdrop1.1a" class= "droppable ui-droppable"></td> <td id="puzdrop1.1b" class= "droppable ui-droppable"></td> <td id="puzdrop1.1c" class= "droppable ui-droppable"></td> <td id="puzdrop1.1d" class= "droppable ui-droppable"></td> <td id="puzdrop1.1e" class= "droppable ui-droppable"></td>              </tr>                <tr>  <td id="puz1.1.6" class= "droppable ui-droppable"></td> <td id="puz1.1.7" class= "droppable ui-droppable"></td> <td id="puz1.1.8" class= "droppable ui-droppable"></td> <td id="puz1.1.9" class= "droppable ui-droppable"></td> <td id="puz1.1.10" class= "droppable ui-droppable"></td>              </tr>                 <tr>  <td id="puz1.1.11" class= "droppable ui-droppable"></td> <td id="puz1.1.12" class= "droppable ui-droppable"></td> <td id="puz1.1.13" class= "droppable ui-droppable"></td> <td id="puz1.1.14" class= "droppable ui-droppable"></td> <td id="puz1.1.15" class= "droppable ui-droppable"></td>              </tr>                         <tr>  <td id="puz1.1.16" class= "droppable ui-droppable"></td> <td id="puz1.1.17" class= "droppable ui-droppable"></td> <td id="puz1.1.18" class= "droppable ui-droppable"></td> <td id="puz1.1.19" class= "droppable ui-droppable"></td> <td id="puz1.1.20" class= "droppable ui-droppable"></td>              </tr>                    <tr>  <td id="puz1.1.21" class= "droppable ui-droppable"></td> <td id="puz1.1.22" class= "droppable ui-droppable"></td> <td id="puz1.1.23" class= "droppable ui-droppable"></td> <td id="puz1.1.24" class= "droppable ui-droppable"></td> <td id="puz1.1.25" class= "droppable ui-droppable"></td>              </tr>              </tbody>     </table>  </div> </div>  </div>      #droppable{     width: 50px;     height:50px;     margin: 0;   }  .droppable{     width:50px;     height: 50px;     background-color: grey; }  #kader table td {     width:50px;     height: 50px;     background-color: grey;     margin: 0;     padding: 0; } #kader {     width: 300px;     height: 300px; } #kader table {     width:270px;     height: 270px;     background-color: blue;     border-collapse: collapse; } 

first: can't have 2 or more elements same id, id must unique.

but may have data attached puzzle pieces:

<img id="piece_01" .. />  <td id="place_01" data="piece_01" ... /> 

or other way round, attaching place id piece. can pick data attribute , compare dropped image id etc.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -