2

画像がクリックされたときに、div を別の div に沿って切り替えたい。開くと、その隣の div が左に押し出されます。横にある div を閉じてトグルすると、元の位置に戻ります...現在行っていることは、その隣の div の上にトグルすることです。これは私のコードです。

   img{
   margin-left:0px;
  }

  #info {
    position: absolute;
    margin-left: 20px;
    margin-top: -310px;
    border: 1px solid black;
    width: 400px;
    height: 308px;
    background-color: #F4F4EE;
   }

   #container {
      border: 1px solid black;
      position: relative;
    }

jQuery...

     $(document).ready( function(){
  hideInfo();
     });

    function hideInfo(){
       $( '#container > div' ).hide();

      $('#container a').click(function(){
      $(this).next().animate({
               width: "toggle",
               height: "toggle"}, 
           {duration: 700, 
            specialEasing: {width: "linear"},
         });
       });
    }

HTML

        <body>
        <div id="container">
   <a href="#"><img src="button.jpg"/></a> /*image must be clicked to toggle the div */
  <div id="info" class="panel">
        Information in div 1
   </div>
           <a href="#"><img src="button2.jpg"/></a               
            <div id="info"  class="panel">
                 information in the second div
         </div>
     <div>
   </body>
4

1 に答える 1