0
I’m starting in jQuery and created a script in which when I click the div displays the content. So far so good, but when you click on text close jquery’s IDE is not working.
jQuery(function(){
//jQuery('#showall').click(function(){
// jQuery('.targetDiv').show();
//});
jQuery('.showSingle').click(function(){
jQuery('.targetDiv').hide();
jQuery('#div'+$(this).attr('target')).show(500).fadeIn();
//Query('.fechar').hide(500).fadeIn();
});
jQuery('.fechar').click(function(){
jQuery('#div'+$(this).attr('target')).hide(500);
});
//$('.fechar').click(function(){
// $(".targetDiv").slideToggle();
// });
});
The script in Jsfinddle
Dude, either you wear Id-show, or you fade-fadeOut, but better is . fadeToggle(), on it You do not need to validate whether the business is hidden or not, the function itself already does that. One more thing, use "$" instead of "jQuery" and ". on('click',Function()" instead of . click(Function().
– Pedro Morais
thanks for the tip. Just takes away a doubt, pq use on('click',Function()" instead of . click(Function()?
– Luis Fernando Mangia
In fact I don’t know for sure, but I remember that whenever I did this I got in a fight with kkkkk. But in the documentation you write . click is a "shortcut" of the on function. ('click'
– Pedro Morais