Reputation: 51
i have written following function in JS which is called on click of some element in Client Side.I want to loop thru in jQuery,but following code is not working.
function HideShowMenu( pStart, pLength)
$(document).ready(function(){
for ( i=pStart ; i <= pLength ; i++ ) {
$('#tr_menu_'+i).show();
}
});
// return
return;
}
How can i go about it?
Upvotes: 0
Views: 84
Reputation: 11557
function HideShowMenu() {
$(document).ready(function(){
$('#tr_menu_').each(function() {
$(this).show();
});
});
}
Upvotes: 0
Reputation: 47099
$(document).ready(function(){
HideShowMenu(0, 5);
});
function HideShowMenu(pStart, pLength) {
for ( var i=pStart; i <= pLength; i++ ) {
$('#tr_menu_' + i).show();
}
}
Upvotes: 1
Reputation: 26921
You are misusing $(document).ready();
. Correct way is something like this:
function HideShowMenu( pStart, pLength){
for (var i=pStart ; i <= pLength ; i++ ) {
$('#tr_menu_'+i).show();
}
}
$(document).ready(function(){
HideShowMenu(1,10);
});
$(document).ready()
should be outside any other function.
Upvotes: 0