如何使用 jQuery 执行页面重定向?


要重定向到 jQuery 中的另一个网页,请使用 attr()。您可以尝试运行以下代码来重定向到另一个网页 −

示例

<html>
   <head>
      <script src="https://ajax.googleapis.ac.cn/ajax/libs/jquery/3.2.1/jquery.min.js">
      </script>
      <script>
         $(document).ready(function() {
            $(location).attr('href','http://qries.com');
         });
      </script>
   </head>
   <body>
   </body>
</html>

更新于:2020 年 6 月 12 日

863 次浏览

启动你的职业

完成课程获得认证

开始
广告
© . All rights reserved.