Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>add a parent <code>&lt;div&gt;</code> in your loop... so that all this html stay inside a parent div.. this way we can use <a href="http://api.jquery.com/parent/" rel="nofollow">parent()</a>..</p> <pre><code>&lt;?php $X = 0; foreach($companyRows as $row){ ?&gt; &lt;div class="parentDiv"&gt; //***here**** &lt;div class="first" &gt; echo "a company information shortend form" &lt;/div&gt; &lt;div class="second" style="display:none"&gt; echo "a company information full form" &lt;/div&gt; &lt;a class="show_details show_more"&gt; show more&lt;/a&gt; //updated &lt;/div&gt; &lt;?php $X++; } ?&gt; </code></pre> <p><strong>JQUERY</strong> *<strong><em>UPDATED</em>*</strong></p> <pre><code>$(document).ready(function(){ $(".show_details").click(function(){ var $this=$(this); var $parent= $this.parent(); if($this.hasClass('show_more')){ $this.removeClass('show_more').addClass('show_less'); $parent.find('.second').show(); //find parent div and div with second class inside that parent div $parent.find(".first").hide(); $this.html('show Less'); // $(this).text('show Less'); }else if($this.hasClass('show_less')){ $this.removeClass('show_less').addClass('show_more'); $parent.find('.second').hide(); //find parent div and div with second class inside that parent div $parent.find(".first").show(); $this.html('show More'); // $(this).text('show Less'); } }); }); </code></pre> <p><a href="http://api.jquery.com/html/" rel="nofollow">html()</a>.. to replace the text inside the clicked link or u can use <a href="http://api.jquery.com/text/" rel="nofollow">text()</a></p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload