Solved

How can incorporate this animated show / hide dynamic into this scenario?

Posted on 2015-02-05
3
54 Views
Last Modified: 2015-02-11
This works:

<!doctype html>
<html lang="en">
<head>  
<meta charset="utf-8">  
<title>jQuery UI Effects - Hide Demo</title>  
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js" type="text/javascript"></script>

 
 <style>
.slidingDiv {
    height:300px;
    background-color: #99CCFF;
    padding:20px;
    margin-top:10px;
    border-bottom:5px solid #3399FF;
}
 
.show_hide {
    display:none;
}


</style>
 
 </head>
 
 <body>
 <script type="text/javascript">
 $(document).ready(function(){
 
        $(".slidingDiv").hide();
        $(".show_hide").show();
 
    $('.show_hide').click(function(){
    $(this).next().slideToggle();
    });
	
});
 </script>
 
 <a href="#" class="show_hide">Show/hide</a>
	<div class="slidingDiv">
	Fill this space with really interesting content. 
	</div>
	<br><a href="#" class="show_hide">Show/hide</a>
	<div class="slidingDiv">
	Fill this space with really interesting content. 
	</div>
</body>
</html>

Open in new window


This does not:

<a href="#" class="show_hide">Show/hide</a>
<table>
	<tbody class="slidingDiv">
		<tr>
			<td>hello</td>
			<td>indeed</td>
		</tr>
	</tbody>
	<tr>
		<td>and...</td>
		<td>not really</td>
	</tr>
</table>
	

Open in new window


What I'm trying to do is achieve the same kind of animated motion with the rows of my table that I have with the slidingDiv div in the first example.

In other words, I want a collection of rows hidden until I click a link, at which point I get that smooth transition of them being revealed.

How?

Looking forward to hearing from minds greater than my own!
0
Comment
Question by:brucegust
  • 2
3 Comments
 
LVL 9

Expert Comment

by:Brian Tao
ID: 40592610
The "next()" of your last "show_hide" is the table and not the tbody tag, so it shows/hides the entire table, and doesn't work on the tbody.
0
 

Author Comment

by:brucegust
ID: 40592620
Brian! Sorry to be such a teacup, but could you show me what it's supposed to look like?
0
 
LVL 9

Accepted Solution

by:
Brian Tao earned 500 total points
ID: 40592643
Actually there's no way of "grouping" a set of rows in a table.  To achieve the expected result, you may want to add the class="slidingDiv" to each row that you want to toggle, and modify your code from
$(this).next().slideToggle();

Open in new window

to
$(".slidingDiv").slideToggle();

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Timerpicker in javascript 4 34
javascript 5 42
Elegant Way to Include Query String When it exists? 4 42
Initialize SharePoint Online List Values in Quick Edit 7 20
This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

943 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

1 Experts available now in Live!

Get 1:1 Help Now