2013-05-16 51 views
0

我有一个jQuery的功能,点击更多的链接后,我会显示指定摘要的更多信息。 我对jQuery相对来说比较新,我希望得到一个指向我要去哪里错误的指针,因为它不能正常工作。通过单击链接按钮显示更多信息更多

$(document).ready(function() { 
$('#more').on("click", function() { 
     "$('#more').hide(); $('#content').show();" 
    }); 

}); 

这是代码我的C#代码背后

topicGenerator.InnerHtml += summary.Substring(1, 100); 
topicGenerator.InnerHtml += "<a href='#' id='more'> more...</a>"; 
topicGenerator.InnerHtml += "<div id='content' style='display:none;'>"+summary+ </div>"; 

亲切的问候

回答

0

这将显示之间切换,隐藏和改变<a>又少了一次更

$(document).ready(function() { 
    $('#more').click(function() { 
      $('#content').toggle(); 
      if($('#more').html()=='more...'){ 
      $('#more').html('less...'); 
    }else{ 
      if($('#more').html()=='less...'){ 
      $('#more').html('more...'); 
    }  
    } 

     }); 

    }); 
+0

并留出一些空间留下更多...在html中的空间 – 2013-05-16 10:48:49

1

尝试改变

"$('#more').hide(); $('#content').show();" 

$('#more').hide(); 
$('#content').show(); 

你不需要在"quotations"来包装这些语句。

你也可以凝结.hide().show().toggle()

<script> 
$(function(){ 
    $("#more").click(function(){ 
    $("#content").toggle(); 
    }); 
}); 
</script> 

fiddle