2012-09-20 27 views
1

我有这样的代码在jQuery来掩饰内心的另一个一个div一个按钮被点击时的工作,它工作在Firefox和Chrome,但不是在IE9:jQuery代码没有按不是在IE

$(document).ready(function() { 
     $("#esconde, #Div1, #Div2").hide(); 
     $("#act2").click(function() { 
      $("#esconde").fadeIn(1000).show().append($("#lista1")); 
      $("#listadefault").remove().fadeOut(500); 

      $("#act3").click(function() { 
       $("#listadefault").remove(); 
       $("#Div1").fadeIn(1000).show().append($("#lista1")); 

       $("#act4").click(function() { 
        $("#Div2").fadeIn(1000).show().append($("#lista1")); 
        $("#listadefault").remove().fadeOut(500); 
       }); 

      }); 
     }); 

,这是html:

<div id="Div1" class="span12"> 
    <table class="well table table-condensed"> 
     <label>tabela 3</label> 
       <thead> 
        <tr> 
         <th>Opção 1</th> 
         <th>Opção 2</th> 
         <th>Opção 3</th> 
        </tr>  

       </thead> 
       <tbody> 
        <tr><td>Dado 1</td><td>Dado 2</td><td> 
         <div class="btn-group" data-toggle="buttons-checkbox"> 
          <button type="button" class="btn btn-primary"> 
           dado1</button> 
         </div> 
        </td> 
        </tr> 
        <tr><td>Dado 1</td><td>Dado 2</td><td><div class="btn-group" data-toggle="buttons-checkbox"> 
          <button type="button" class="btn btn-primary"> 
           dado1</button> 
         </div></td></tr> 
        <tr><td>Dado 1</td><td>Dado 2</td><td><input type="button" data-toggle="buttons-checkbox" class="btn btn-primary" /></td></tr> 
        <tr><td>Dado 1</td><td>Dado 2</td><td><input type="checkbox" /></td></tr> 
       </tbody> 


      </table> 
    </div> 

这个div应该出现在#lista1 div中。

感谢名单

+2

你得到任何错误?检查控制台 –

+2

你能提供有关[的jsfiddle]演示(http://jsfiddle.net)? – undefined

回答

0

你nisting对方内线的所有点击事件:

试试这个:

$(document).ready(function() { 
     $("#esconde, #Div1, #Div2").hide(); 
     $("#act2").click(function() { 
      $("#esconde").fadeIn(1000).show().append($("#lista1")); 
      $("#listadefault").remove().fadeOut(500); 
     }); 

      $("#act3").click(function() { 
       $("#listadefault").remove(); 
       $("#Div1").fadeIn(1000).show().append($("#lista1")); 
      }); 
       $("#act4").click(function() { 
        $("#Div2").fadeIn(1000).show().append($("#lista1")); 
        $("#listadefault").remove().fadeOut(500); 
     }); 
    }); 
0

我知道这是不相关的任何方式你的问题,但看后在您的JavaScript我不能不注意到,您正在执行上不作一大堆的传感元件的一些行动。我的意见是内联:

$(document).ready(function() { 
     $("#esconde, #Div1, #Div2").hide(); 
     $("#act2").click(function() { 
      $("#esconde").fadeIn(1000).show().append($("#lista1")); 
      $("#listadefault").remove().fadeOut(500); // Fading out an element which is already removed 

      // Attaching an event handler after a click event is handled. 
      // This actually repeats every time you click and even if it's intentional you should perform .one() instead of click, so you don't bind multiple times 
      $("#act3").click(function() { 
       $("#listadefault").remove(); 
       $("#Div1").fadeIn(1000).show().append($("#lista1")); // Showing an element which is shows. FadeIn shows the element. 

       $("#act4").click(function() { 
        $("#Div2").fadeIn(1000).show().append($("#lista1")); // Same thing with fadeIn and show as the above comment. 
        $("#listadefault").remove().fadeOut(500); // Same thing with remove and fadeOut 
       }); 

      }); 
     }); 
+0

感谢名单康斯坦丁Dinev和AboQutiesh,我忘了提,进出口新的jQuery和没有很多xperience的。现在的工作,但我还有一个问题,林筑巢这些活动,他们的工作从上到下,使用后,如果我尝试做backwords它不工作了,任何提示??? – CodigoNinja