I need some help with this jQuery code. The code below works fine but i tried to use $.each instead and its not working.
$(document).ready( function(){
$('#pull').click( function(event){
event.stopPropagation();
$('#pf').slideToggle();
});
$('#pullo').click( function(event){
event.stopPropagation();
$('#pt').slideToggle();
});
$('#pullc').click( function(event){
event.stopPropagation();
$('#pc').slideToggle();
});
$(document).click( function(){
$('#pt').hide();
$('#pf').hide();
$('#pc').hide();
});
});
The code below is not working for me, please help
var pul = ["#pull":"#pt","#pullo":"#pf", "#pullc":"#pc"];
$(document).ready( function(){
$.each(pul, function(i, v){
$(i).click( function(event){
event.stopPropagation();
$(v).slideToggle();
});
$(document).click(function(){
$(v).hide();
});
});
});
pularray should be an object, that's invalid JavaScript. It seems you want to refactor the script. Can you post the HTML?#ptand#pf.documentall of your elements will.hide().