选项卡式内容不适用于Chrome和Firefox,但适用于IE

tabbed content not working in Chrome and Firefox but works in IE

本文关键字:适用于 Firefox IE Chrome 选项 不适用      更新时间:2023-09-26

我有这个index.js,它包含了我的大部分函数,比如:

      // a and b is placed at index.jsp 
$("#a").click(function (){  //this works on index.jsp and display.jsp(where the servlets forwards it).
      $("#b").load('servletA.html?action=display');
 });

在我的index.jsp和display.jsp上,我还有另一个选项卡内容.js导入,问题是当我只运行display.jsp时,选项卡内容有效。但不幸的是,如果我在index.jsp上单击#a,则选项卡式内容不起作用。我想知道为什么Chrome和Firefox没有。但它确实适用于IE(所有版本(。

编辑:

这是display.jsp 的代码剪切器

 // imports
  <script src="js/tabcontent.js"></script>
    <ul class="tabs">
      <li><a href="#view1">Main</a></li>
      <li><a href="#view2">OTHERS</a></li>
   </ul>
    <div class="tabcontent">
        <div id="view1">
              // SOME CONTENT HERE
        </div>
        <div id="view2">
              // SOME CONTENT HERE
        </div>

正确的方法是这样

$("#b").load('servletA.html', {action: 'display'});

它可能会对你有所帮助。阅读更多关于jQuery.load((.的信息

基本上这就是的语法

$('#mydiv').load('newPage.html', {field1: 'value1', ...});

再次验证CCD_ 2的路径。尝试使用/servletA.html