Hey all, I'm using the toggle() function to show/hide some div with a form that I have here. Below that div there's another div, which is clickable and it's text alternates whenever the display of the above div is changed.
All is working that way. The problem is that on some pages I need that div to start with display:block and not display:none (default). And when I define that, the text doesn't check for the div display upon the load of the page. That causes to when I set the div to start with display:block (showing) on that particular page, the text says "Click here to open the div"... That's the mess that is happening here. So I thought on create some function that upon the body onload, would check how is the display of that div, and so change the text to display the current info: "Click here to hide" when the div is opened (display:block), and "Click here to show" when the div is hidden (display:none). Here is the current code: $(document).ready(function(){ function checa_botao() { var am = $("a#mostra"); var fc = $("#form_consulta"); ((fc.css("display") == "block") ? am.text("Click here to show") : am.text("Click here to hide")); } checa_botao(); //Alternar exibição do form $("a#mostra").click(function () { checa_botao(); $("#form_consulta").slideToggle("fast"); }); } But it's not working. When loading the page, even with that function, the text isnt changing according to the div state (none or block). Any ideas? Thanks.