w3school include HTML, javascript not working

后端 未结 2 797
谎友^
谎友^ 2021-01-25 03:45

So, I recently used w3school include html, so that i dont have to copy-paste same div to all my pages.

First, i used it for header and footer, which uses some CSS styli

2条回答
  •  傲寒
    傲寒 (楼主)
    2021-01-25 04:08

    Now w3.includeHTML from w3.js allows a callback after html is loaded.

    w3.includeHTML(function() { 
      $('#leftDrop1').on('click', function() {
        if ($('#sub1').css('display') == 'block') {
          $('#sub1').hide()
        } else {
          $("#sub1").show()
        }
      })
      $('#leftDrop2').on('click', function() {
        if ($('#sub2').css('display') == 'block') {
          $('#sub2').hide()
        } else {
          $("#sub2").show()
        }
      })
    });
    

提交回复
热议问题