code_junkie

jquery hide show div problem (internet explorer)

Nov 14th, 2011
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. $(document).ready(function(){
  2. $("#togglediv").click(function(){
  3. if($("#commentdiv").is(":visible")){
  4. $("#commentdiv").hide("slow"); $("#togglediv").text("show");}
  5. else{
  6. $("#commentdiv").show("slow"); $("#togglediv").text("hide");}
  7. }
  8. });
  9.  
  10. $(document).ready(function() {
  11. $("#togglediv").click(function() {
  12. // note: do this first because the :hidden test fails if you
  13. // do it after triggering a slow animation
  14. $("#togglediv").text($("#commentdiv").is(":hidden") ? "Hide" : "Sgiw");
  15. $("#commentdiv").toggle('slow');
  16. });
  17. });
  18.  
  19. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  20. <html>
  21. <head>
  22. <title>Test</title>
  23. <style type="text/css">
  24. #togglediv { padding: 5px; background-color: yellow; }
  25. #commentdiv { padding: 5px; background-color: #CCC; height: 100px; }
  26. </style>
  27. </head>
  28. <body>
  29. <div id="togglediv">Hide</div>
  30. <div id="commentdiv">thanks for answer. but i have tried this code, it was okay. i want to use toggle("slow") effect. this effect is runing firefox, but not i.e. is it a bug?</div>
  31. <script type="text/javascript" src="jquery-1.3.1.js"></script>
  32. <script type="text/javascript">
  33. $(function() {
  34. $("#togglediv").click(function() {
  35. $("#togglediv").text($("#commentdiv").is(":hidden") ? "Hide" : "Show");
  36. $("#commentdiv").toggle('slow');
  37. });
  38. });
  39. </script>
  40. </body>
  41. </html>
  42.  
  43. $("#commentdiv").toggle("slow");
  44.  
  45. $(document).ready(function(){
  46. $("#togglediv").click(function(){
  47. if($("#commentdiv").is(":visible")){
  48. $("#commentdiv").hide("slow"); $("#togglediv").text("show");
  49. }
  50. else{
  51. $("#commentdiv").show("slow"); $("#togglediv").text("hide");
  52. }
  53. }
  54. });
  55.  
  56. if(document.getElementById(ThisObj).style.display == 'none')
  57. {
  58. document.getElementById(ThisObj).style.display = 'block';
  59. }
  60. else
  61. {
  62. document.getElementById(ThisObj).style.display = 'none';
  63. }
Add Comment
Please, Sign In to add comment