jquery - Trouble hidding div with javascript -


i'm having trouble javascript coding skills below par. trying create simple pop box (which can sort of do) unable close box. have code written, pasted previous work , edited bit, know rough i'm real novice @ js. heres jsfiddle...http://jsfiddle.net/4v4txoxs/2/ thanks

$('.up').click(function () {     var show = $('.show');      if (show.hasclass('visible')) {         $('.popup').animate({             "opacity": "0"         }, "fast");         $('.popup').animate({             "z-index": "2"         }, "fast");     } else {         $('.popup').animate({             "opacity": "1"         }, "fast");         $('.popup').animate({             "z-index": "5"         }, "fast");     } }); 

you need show , hide class visible, can achieve using $.fn.toggleclass().

//added line before if block show.toggleclass('visible'); 

demo


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -