2014-12-24 112 views
0

我正在使用引导和使2列和一个按钮,我想要做的时候我点击按钮将显示4列而不是2列的一行。jquery slidetoggle模板

JQuery的

$( '#more_service')。在( '点击',函数(){

$('.service_container').slideToggle('slow',function(){  

      var template = $('item_template').html(); 
      $('.service_wrapper').html(template);  

       }); 
     }); 

HTML


创意服务

 <div class="row"> 
      <div class="span4"> 
       <img src="img/web-developing.png" class="img-responsive center-block" alt="" /> 
       <h3 class="red-text text-center">Creative Service</h3> 
       <p class="webdev text-center">aaaaaaaaaaaaa</p> 
      </div> 
      <div class="span4"> 
       <img src="img/branding.png" class="center-block" alt="" /> 
       <h3 class="red-text text-center">Branding</h3> 
       <p class="webdev text-center">aaaaaaaaaaaaaaaaaa</p> 
      </div>   </div>   <div class="row"> 
      <div class="span4"> 
       <img src="img/web-developing.png" class="img-responsive center-block" alt="" /> 
       <h3 class="red-text text-center">Creative Service</h3> 
       <p class="webdev text-center">aaaaaaaaaaaaa</p> 
      </div> 
      <div class="span4"> 
       <img src="img/branding.png" class="center-block" alt="" /> 
       <h3 class="red-text text-center">Branding</h3> 
       <p class="webdev text-center">aaaaaaaaaaaaaaaaaa</p> 
      </div>   </div> 


          </div> </script> 
+0

$(container).append(''); 您可以像这样动态地调整元素。我使用了可以随意添加的文本框。 – Naitik

+0

你的html的more_service,service_container,item_template和service_wrapper在哪里? –

+0

给一个小提琴... –

回答

0

$( 'item_template')HTML()。是代码中的元素,就像一个类或一个ID?如果是这样,你需要添加一个点或者像哈希标签:

$('item_template').html(); 

成为

$('#item_template').html(); or $('.item_template').html(); 
0

如果item_template是ID使用#如果类使用.和使用innerHTML

var template = $('#item_template').innerHTML; 
+0

它工作我的问题是下一次当我点击按钮不工作。 – Shecode