troubleshooting Question

JQuery - Toggle

Avatar of csehz
csehzFlag for Hungary asked on
Web Languages and StandardsJavaScript
5 Comments1 Solution561 ViewsLast Modified:
Dear Experts,

In the attached small code I am just trying the JQuery bases, could you please advise how a condition could be put to it?

I would like that the <h2> element would be toggled only, if its node value is "This is also a h2 element", so only the second one.


	<script src="" type="text/javascript" charset="utf-8"></script>       
	<script type="text/javascript">                                       
		$(document).ready(function() {
			$("h1").click(function() {
<h1>Click to here to hide the h2 element</h1>
<h2>This is a h2 element</h2>
<h2>This is also a h2 element</h2>                                  
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 5 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros