我使用w3-include-html作为页眉和页脚代码,但出于某种原因,当屏幕尺寸较小时,在页脚中添加一个类的javascript将无法正常工作,如果我不做w3则可行-include-HTML
我发现了一些但在我的情况下无法理解如何做到这一点。 这是我找到的,
w3school include HTML, javascript not working
这是javascript,
(function($) {
var $window = $(window),
$html = $('.footlogo_container');
function resize() {
if ($window.width() < 600) {
return $html.addClass('col-xs-15');
}
$html.removeClass('col-xs-15');
}
$window
.resize(resize)
.trigger('resize');
})(jQuery);
这就是footer.html中的内容
<footer class="footer" style="margin-bottom: -2%;padding-top: 7%" >
<div class="footer-top ">
<div class="container" id="cont">
<div class="row">
<div class="footer-col col-md-3 col-sm-3 ">
</div>
<div class="footer-col col-md-3 col-sm-3 ">
</div>
<div class="footer-col col-md-3 col-sm-3 ">
</div>
<div class=" footer-col col-md-3 col-sm-3 footlogo_container" style="cursor: pointer;background: url('logo_imageroots.png');background-size: cover;background-position: center;" onclick="location.href='index.html';">
</div>
</div>
</div>