javascript oder jquery, Klicken Sie auf den link und erweitern Sie div

Bin ich auf der Suche js/jquery-Lösung auf dem Netz und stackoverflow für ein div hat eine Höhe festlegen (Beispiel 20px;) und nachdem der Benutzer klickt auf [mehr] öffnet es auf eine Höhe von auto oder 150px; (full content)

Beispiel:

<style>
.small  {height: 20px;}
.big    {height: auto;}
</style>


<div class="small">
    <p>Lorenter code hereem ipsum dolor sit amet, consectetur adipisicing elit, sed do
    eiusmod tempor incididunt ut labore et dolore magna aliqua.
    Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris
    nisi ut aliquip ex ea commodo consequat. Lorem ipsum dolor sit amet,
    consectetur adipisicing elit, sed do eiusmod tempor incididunt
    ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis
    nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
    consequat.</p>
    <a href="#">Click to read more</a>
</div>

Danke für die Hilfe.

EDIT: Ich habe versucht diese:

In das "href": onclick="javascript:toggleContent(this, true);"

Zusammen mit diesem:

<script type='text/javascript'>
$(window).load(function(){
comment_reply = function (id){

   var e = $(id);
   e.toggle();
}
}); 
</script>

Das problem ist das div-erweitert klicken Sie auf, anstatt eine [a href] ich hoffe, das ist klar.

  • Sorry, aber wo sind Sie stecken geblieben???
  • Können Sie uns sagen, was Sie haben, trid, bis jetzt?
  • Ah, sorry, sollte ich das geklärt haben. Ich weiß nicht, wie es zu tun. Ich bin kein JS. Die einzige option, die Ich fand, um zu arbeiten war, klicken Sie auf die div-und erweitert es. Aber mit hyperlinks in meinem content-öffnet oder schließt das div und geht dann auf die url. Nicht eine saubere option.
  • Ich habe versucht diese:<script type='text/javascript'> $(window).load(function(){ comment_reply = function (id){ var e = $(id); e.toggle(); } }); </script> mit: onclick="javascript:toggleContent(this, true);"
  • jede Antwort, die-unten sind mit jQuery... wenn Sie nicht fügen Sie es doch zu Ihrem Projekt, müssen Sie zu : <script src="http://code.jquery.com/jquery-git.js" type="text/javascript"></script>
InformationsquelleAutor James | 2013-11-22
Schreibe einen Kommentar