user3265085
user3265085

Reputation: 25

Using Jquery function 's argument to run different result

I am using 2 functions to hide and show all different divs in my html. I'm trying to pass a parameter into the function and use if condition to hide or show different div.

Here is my Jquery Hide function

function HideDivs(content){
   if(content==="list"){
       $("div#temp_block").hide();
   }else if(content==="midbtn"){
       $(".search_midbtns").hide();
   }else if(content==="result"){
       $(".search_result").hide();
   }else if(content==="edit"){
       $("#edit_data").hide();
   }

}

and i am using it inside the document ready function

HideDivs("result");
HideDivs("midbtns");

but i can't hide these divs. Is there a way to do this ? I am having so many div to hide and show. Hope this would be a better way to view the js code.

Upvotes: 0

Views: 32

Answers (1)

beautifulcoder
beautifulcoder

Reputation: 11320

Check your strings "midbtns" !== "midbtn" also check that your class names match.

Upvotes: 1

Related Questions