jquery.toggle.js 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. /*
  2. * jQuery Toggle
  3. */
  4. $(document).ready(function(){
  5. //hide the all of the element with class session_course_item
  6. $(".session_box").show();
  7. $(".session_course_item").show();
  8. //toggle the componenet
  9. $("div.session_category_title_box").click(function(){
  10. category_image = $(this).attr("id").split("_");
  11. category_real_image_id = category_image[category_image.length-1];
  12. image_clicked = $("#category_img_"+category_real_image_id).attr("src");
  13. image_clicked_info = image_clicked.split("/");
  14. image_real_clicked = image_clicked_info[image_clicked_info.length-1];
  15. image_path = image_clicked.split("img");
  16. current_path = image_path[0]+"img/";
  17. if (image_real_clicked == 'div_show.gif') {
  18. current_path = current_path+'div_hide.gif';
  19. $("#category_img_"+category_real_image_id).attr("src", current_path);
  20. } else {
  21. current_path = current_path+'div_show.gif';
  22. $("#category_img_"+category_real_image_id).attr("src", current_path)
  23. }
  24. $(this).nextAll().slideToggle("fast");
  25. });
  26. $("li.session_box_title").click(function(){
  27. session_image = $(this).attr("id").split("_");
  28. session_real_image_id = session_image[session_image.length-1];
  29. image_clicked = $("#session_img_"+session_real_image_id).attr("src");
  30. image_clicked_info = image_clicked.split("/");
  31. image_real_clicked = image_clicked_info[image_clicked_info.length-1];
  32. image_path = image_clicked.split("img");
  33. current_path = image_path[0]+"img/";
  34. if (image_real_clicked == 'div_show.gif') {
  35. current_path = current_path+'div_hide.gif';
  36. $("#session_img_"+session_real_image_id).attr("src", current_path)
  37. } else {
  38. current_path = current_path+'div_show.gif';
  39. $("#session_img_"+session_real_image_id).attr("src", current_path)
  40. }
  41. $(this).nextAll().slideToggle("fast");
  42. });
  43. });