-1

我一直在尝试运行一个基本的 jQuery 步骤示例,但无法这样做。这段代码有问题吗?jquery.steps.js 插件与 html 文档位于同一文件夹中

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">  </script>
<script src="jquery.steps.js"></script>
</head>
<body>
<script>
$("#example-basic").steps({
headerTag: "h3",
bodyTag: "section",
transitionEffect: "slideLeft",
autoFocus: true
});


</script>

<div id="example-basic">
<h3>Keyboard</h3>
<section>
<p>Try the keyboard navigation by clicking arrow left or right!</p>
</section>
<h3>Effects</h3>
<section>
<p>Wonderful transition effects.</p>
</section>
<h3>Pager</h3>
<section>
<p>The next and previous buttons help you to navigate through your content.</p>
</section>
</div>



</body>
</html>
4

1 回答 1

0

因为您在页面上呈现元素之前运行代码。

要么将脚本块移动到页面上的元素之后,要么将内容包装在document ready中。

$(function() {  //shortcut for document ready
    $("#example-basic").steps({
        ...
    });
});
于 2014-12-18T19:12:51.090 回答