Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery html css slidetoggle effect
    primarykey
    data
    text
    <p>I'm trying to make a movie booking system website which also has info on movies. I want to implement a mechanism where when a user clicks on the poster of a particular movie, its info(description and cast) shows up and slides down. I have achieved this. But the problem I'm having is, when a description of a particular movie slides downwards, every other movie poster in the same row slide down with it. What I want is for every other element to remain static. </p> <p><strong>Here is my HTML code:</strong></p> <pre><code> &lt;div class="contents"&gt; &lt;table id="movies"&gt; &lt;tr&gt; &lt;td class="Horror"&gt;&lt;img id="Image1" src="&lt;?php echo "$image_1"; ?&gt;" width=250 height=400&gt; &lt;p&gt;&lt;?php echo "Name: $name_1";?&gt;&lt;/p&gt; &lt;p class="description" id="desc1"&gt;&lt;?php echo "&lt;span&gt;Description:&lt;/span&gt; $description_1"?&gt; &lt;p class="cast" id="cast1"&gt; &lt;?php echo "&lt;span&gt;Cast:&lt;/span&gt; $cast_1" ?&gt;&lt;/p&gt;&lt;/td&gt; &lt;td class="Action"&gt;&lt;img id="Image2" src="&lt;?php echo "$image_2"; ?&gt;" width=250 height=400&gt; &lt;p&gt;&lt;?php echo "Name: $name_2";?&gt;&lt;/p&gt; &lt;p class="description" id="desc2"&gt;&lt;?php echo "&lt;span&gt;Description:&lt;/span&gt; $description_2"?&gt; &lt;p class="cast" id="cast2"&gt; &lt;?php echo "&lt;span&gt;Cast:&lt;/span&gt; $cast_2" ?&gt;&lt;/p&gt;&lt;/td&gt; &lt;td class="Action"&gt;&lt;img id="Image3" src="&lt;?php echo "$image_3"; ?&gt;" width=250 height=400&gt; &lt;p&gt;&lt;?php echo "$name_3";?&gt;&lt;/p&gt; &lt;p class="description" id="desc3"&gt;&lt;?php echo "&lt;span&gt;Description:&lt;/span&gt; $description_3"?&gt; &lt;p class="cast" id="cast3"&gt; &lt;?php echo "&lt;span&gt;Cast:&lt;/span&gt;$cast_3" ?&gt;&lt;/p&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td class="Action"&gt;&lt;img id="Image4" src="&lt;?php echo "$image_4"; ?&gt;" width=250 height=400&gt; &lt;p&gt;&lt;?php echo "Name: $name_4";?&gt;&lt;/p&gt; &lt;p class="description" id="desc4"&gt;&lt;?php echo "&lt;span&gt;Description:&lt;/span&gt; $description_4"?&gt; &lt;p class="cast" id="cast4"&gt; &lt;?php echo "&lt;span&gt;Cast:&lt;/span&gt; $cast_4" ?&gt;&lt;/p&gt;&lt;/td&gt; &lt;td class="Horror"&gt;&lt;img id="Image5" src="&lt;?php echo "$image_5"; ?&gt;" width=250 height=400&gt; &lt;p&gt;&lt;?php echo "Name: $name_5";?&gt;&lt;/p&gt; &lt;p class="description" id="desc5"&gt;&lt;?php echo "&lt;span&gt;Description:&lt;/span&gt; $description_5"?&gt; &lt;p class="cast" id="cast5"&gt; &lt;?php echo "&lt;span&gt;Cast:&lt;/span&gt; $cast_5" ?&gt;&lt;/p&gt;&lt;/td&gt; &lt;td class="Comedy"&gt;&lt;img id="Image6" src="&lt;?php echo "$image_6"; ?&gt;" width=250 height=400&gt; &lt;p&gt;&lt;?php echo "Name: $name_6";?&gt;&lt;/p&gt; &lt;p class="description" id="desc6"&gt;&lt;?php echo "&lt;span&gt;Description:&lt;/span&gt; $description_6"?&gt; &lt;p class="cast" id="cast6"&gt; &lt;?php echo "&lt;span&gt;Cast:&lt;/span&gt; $cast_6" ?&gt;&lt;/p&gt;&lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/div&gt; &lt;script type="text/javascript" src="js/jquery.js"&gt;&lt;/script&gt; &lt;script type="text/javascript" src="js/show.js"&gt;&lt;/script&gt; </code></pre> <p><strong>And this is my CSS:</strong></p> <pre><code> td .description{ display:none; padding:40px; /*background-image: url('Images/desc_back.jpg');*/ background-color: rgba(230, 230, 239, 0.3); color:#222; position:relative; right:-120px; top:-290px; /*margin:0, auto;*/ border: 3px solid transparent; border-radius: 10px; overflow:hidden; } td .cast { display:none; /*background-color: rgba(34, 34, 34, 0.4); color:#f3f2f1;*/ background-color: rgba(230, 230, 239, 0.3); color:#222; position:relative; right:-120px; top:-290px; border: 3px solid transparent; border-radius: 10px; } span{ font-size:16px; font-weight: bold; text-decoration: underline; } </code></pre> <p><strong>and my jQuery:</strong></p> <pre><code> $('document').ready(function(){ var count=1; $('#Image1').click(function(){ if(count === 1){ $('#desc1').slideToggle('slow'); $('#cast1').slideToggle('slow'); count=0; } else{ $('#cast1').slideToggle('fast'); $('#desc1').slideToggle('fast'); count=1; } }); $('#Image2').click(function(){ if(count === 1){ $('#desc2').slideToggle('slow'); $('#cast2').slideToggle('slow'); count=0; } else{ $('#cast2').slideToggle('fast'); $('#desc2').slideToggle('fast'); count=1; } }); $('#Image3').click(function(){ if(count === 1){ $('#desc3').slideToggle('slow'); $('#cast3').slideToggle('slow'); count=0; } else{ $('#cast3').slideToggle('fast'); $('#desc3').slideToggle('fast'); count=1; } }); $('#Image4').click(function(){ if(count === 1){ $('#desc4').slideToggle('slow'); $('#cast4').slideToggle('slow'); count=0; } else{ $('#cast4').slideToggle('fast'); $('#desc4').slideToggle('fast'); count=1; } }); $('#Image5').click(function(){ if(count === 1){ $('#desc5').slideToggle('slow'); $('#cast5').slideToggle('slow'); count=0; } else{ $('#cast5').slideToggle('fast'); $('#desc5').slideToggle('fast'); count=1; } }); $('#Image6').click(function(){ if(count === 1){ $('#desc6').slideToggle('slow'); $('#cast6').slideToggle('slow'); count=0; } else{ $('#cast6').slideToggle('fast'); $('#desc6').slideToggle('fast'); count=1; } }); }); </code></pre> <p>What I want to achieve is only want my description and cast to slide and keep everything else fixed. Really appreciate any help I get. </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.
 

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