我正在使用材质设计滚动标签。使用jquery动态添加选项卡不能正常工作。问题是当添加标签超过屏幕宽度箭头导航时,不会调整屏幕大小。
我知道为什么标签更改不起作用。但请帮我导航
var countLi = 0;
var add = function(){
$('#tabTitle .is-active').removeClass('is-active');
$('#tabContent .is-active').removeClass('is-active');
countLi = countLi+1;
var a = $('<a href="#'+countLi+'" class="mdl-layout__tab is-active">Tab 2</a>');
var tabTitle = $('#tabTitle');
var tabContent = $('#tabContent')
a.appendTo(tabTitle);
newSec = $('<section class="mdl-layout__tab-panel is-active" id="'+countLi+'"></section>');
newDiv = $('<div class="page-content"></div>');
data = "<form></form>"; //loaded from ajax request
debugger;
newDiv.html(data);
newDiv.appendTo(newSec);
newSec.appendTo(tabContent);
}
&#13;
<html>
<head>
<!-- Material Design Lite -->
<script
src="https://code.jquery.com/jquery-3.1.1.min.js"
integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
crossorigin="anonymous"></script>
<script src="https://code.getmdl.io/1.3.0/material.min.js"></script>
<link rel="stylesheet" href="https://code.getmdl.io/1.3.0/material.indigo-pink.min.css">
<!-- Material Design icon font -->
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons">
</head>
<body>
<!-- Simple header with scrollable tabs. -->
<div class="mdl-layout mdl-js-layout mdl-layout--fixed-header">
<header class="mdl-layout__header">
<!-- Tabs -->
<div class="mdl-layout__tab-bar mdl-js-ripple-effect" id="tabTitle">
<a href="#scroll-tab-6" class="mdl-layout__tab is-active">Tab 6</a>
</div>
</header>
<main class="mdl-layout__content" id="tabContent">
</section>
<section class="mdl-layout__tab-panel is-active" id="scroll-tab-6">
<div class="page-content"><!-- Your content goes here --></div>
</section>
</main>
<button onclick="add()" type="button">add</button>
</div>
</body>
</html>
&#13;