星火官网,前端页面(前台)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

header.js 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. $(function() {
  2. $(".header_box .header_left").click(function () {
  3. if (window.location.pathname !== "/index.html") {
  4. window.location.href = "/index.html";
  5. }
  6. });
  7. let nav_info = $(".header_root").data("nav_info");
  8. $(".header_box > .header_right > .header_nav_item").removeClass("selected");
  9. if (nav_info) {
  10. $(".header_box > .header_right > .header_nav_item.nav_" + nav_info).addClass("selected");
  11. }
  12. $(".header_box > .header_right").on("click", ".header_nav_item", function (ev) {
  13. $(".header_box > .header_right > .header_nav_item").removeClass("selected");
  14. let nav_num = $(this).data("nav");
  15. $(".header_box > .header_right > .header_nav_item.nav_" + nav_num).addClass("selected");
  16. if (nav_num === 1) {
  17. if (window.location.pathname !== "/sections/product.html") {
  18. window.location.href = "/sections/product.html";
  19. }
  20. } else if (nav_num === 2) {
  21. if (window.location.pathname !== "/sections/service.html") {
  22. window.location.href = "/sections/service.html";
  23. }
  24. } else if (nav_num === 3) {
  25. if (window.location.pathname !== "/sections/about.html") {
  26. window.location.href = "/sections/about.html";
  27. }
  28. } else if (nav_num === 4) {
  29. if (window.location.pathname !== "/sections/trial.html") {
  30. window.location.href = "/sections/trial.html";
  31. }
  32. } else if (nav_num === 5) {
  33. if (window.location.pathname !== "/sections/news.html") {
  34. window.location.href = "/sections/news.html";
  35. }
  36. }
  37. });
  38. let _pathname = window.location.pathname;
  39. if (_pathname === "/index.html" || _pathname === "/") {
  40. $(window).on("scroll", function() {
  41. let top = $(window).scrollTop();
  42. if(top > 100){
  43. $(".header_root").addClass("bg_white");
  44. } else {
  45. $(".header_root").removeClass("bg_white");
  46. }
  47. });
  48. }
  49. });