Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jquery show/hide not working

Tags:

html

jquery

I have this jquery script which suppose to hide/show div element base on the hyperlink that is clicked. I don't know why but it's not working at all. The following is the except of my code.

function hide_current_commoncontainer(commoncontainer){
   $(commoncontainer).each(function(){
 if(this.is(":visible")){this.hide();} 
 });
}

function init(){
$("#compose_link").bind("click",function(){
 hide_current_commoncontainer(".pmcommoncontainer");
 ("#composer").show();  
 return false;
 }
);

if(Drupal.jsEnabled){  
 $(document).ready(init);
} 

I've pinpoint the cause and found out that it is show/hide function which is not working. The rest - function calls - are ok. Can anyone tell me where I am doing wrong? Where should I amend my code in order to hide/show div element as the way I wanted.

like image 644
Andrew Avatar asked Dec 30 '25 07:12

Andrew


1 Answers

Ok I found out why $("#composer").show() is not working. It's because I hard-coded the visibility style of those divs to "hidden" and jquery's "show" method can't revert that. Strangely, as opposed to "show" method, "hide" can revert hard-coded "visible" style with no problem. So, to hide/show elements as intended, I either have to use hide/show method combo without no visibility style hard-coding or use css method of jquery and set the visibility style as desire.

like image 62
Andrew Avatar answered Jan 01 '26 19:01

Andrew