javascript - Cant toggle ul with jquery -
any ideas why cant toggle unordered list? supposed target li
items instead of whole menu class?
<!doctype html> <html lang="en"> <head> <script src="cae.js"></script> <title> code academy examples </title> </head> <body> <ul class="menu"> <li>item 1</li> <li>item 2</li> </ul> <button type="submit" class="btn" title="show/hide">click here</button> </body> </html>
$(document).ready(function(){ $( ".btn" ).click( function(){ $( ".menu" ).toggle(); }); });
below may work:
$(document).ready(function(){ $( ".btn" ).click( function(){ $( ".menu li" ).toggle(); }); });
at same time, must include jquery
thanks
javascript jquery html
No comments:
Post a Comment