jquery - Click & Show only if there is an existing div class -


my old question: one page fadein & fadeout transition logic

the code works pretty good, have issue. in navigation system there menu's submenus, aka drop-down menus. if menu link clicked no content, sub-menus, content page loaded blank, until click has content class.

here simple jsfiddle example: http://jsfiddle.net/qukhn/1/

i want load content, if there content corresponding menu link id. if "contact us" clicked in example, don't want try load un-existing div called "contactus content".

is possible? have tried few things hasclass() function, failed succeed.

thanks taking time read , understand.

you can try this:

$("ul li ").click(function() { var cls = $(this).attr('id') if ($('div.content.' + cls).length > 0) { $(".content").fadeout(500); $('.' + cls).delay(500).fadein(1000); } return false; }) 

demo


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -