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.
thanks,
<html> <head> <script src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js" type="text/javascript" charset="utf-8"></script> <script type="text/javascript"> $(document).ready(function() { $("h1").click(function() { $('h2').slideToggle(); }); }); </script> </head> <body> <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> </body> </html>
Open in new window