sách gpt4 ai đã đi

javascript - 外部 jQuery 文件似乎没有执行

In lại 作者:行者123 更新时间:2023-11-28 02:47:36 26 4
mua khóa gpt4 Nike

对 HTML/jQuery 和 Stack 本身非常陌生,所以请多多包涵。

我的问题是,当我运行 index.html 文件时,它似乎没有执行我在外部 .js 文件中告诉它执行的操作。我正在尝试将一个简单的 Accordion 合并到网页中。

Accordion 本身出现在网页中,但它的交互功能(即它的扩展)似乎不起作用。

我怀疑这是一个很容易解决的问题。然而,我在这里。

HTML 文件:index.html

CSS 文件:style.css

JS 文件:accordian.js

$(tài liệu).ready(hàm() {

var acc = document.getElementsByClassName("accordion");
var i;

for (i = 0; i < acc.length; i++) {
acc[i].onclick = function() {
this.classList.toggle("active");
var panel = this.nextElementSibling;
if (panel.style.maxHeight) {
panel.style.maxHeight = null;
} khác {
panel.style.maxHeight = panel.scrollHeight + "px";
}
}
}
});
* {
lề: 0;
đệm: 0;
}

thân hình {
lề: 0;
đệm: 0;
width: 100%;
background-color: #ffffff;
overflow: scroll;
overflow-x: hidden;
font-family: 'Arial', serif;
}

.menu {
width: 100% height: 65%;
float: right;
background-color: #ffffff;
}

.menu>menu-content {
width: 200px;
height: 65px;
float: right;
font-family: 'Arial', serif;
font-size: 20px;
font-weight: đậm;
letter-spacing: -0.05em;
vị trí: tương đối;
color: #ffffff;
}

.menu>menu-content>a {
color: #ffffff;
text-decoration: none;
}

.NavBar {
background-color: #000000;
list-style: không có;
căn chỉnh văn bản: ở giữa;
vertical-align: middle;
line-height: 100px;
width: 100%;
}

.NavBar>li {
hiển thị: khối nội tuyến;
padding-right: 50px;
font-size: 15px;
}

.NavBar>li>a {
text-decoration: none;
color: #ffffff;
}

.NavBar>li>a:hover {
color: #c5c5c5;
}

.banner>.banner-pic {
width: 100%;
hiển thị: khối;
}

.about-section {
font-size: 18px;
căn chỉnh văn bản: ở giữa;
color: #000000;
padding: 40px 70px 40px 70px;
}

.about-section>p {
font-size: 15px;
căn chỉnh văn bản: ở giữa;
margin-top: 20px;
}

.toptips-section {
font-size: 18px;
căn chỉnh văn bản: ở giữa;
color: #000000;
padding: 40px 70px 40px 70px;
}

.toptips-section>p {
font-size: 15px;
căn chỉnh văn bản: ở giữa;
margin-top: 20px;
}

button.accordion {
background-color: #eee;
color: #444;
cursor: pointer;
padding: 18px;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 15px;
transition: 0.4s;
}

button.accordion.active,
button.accordion:hover {
background-color: #ccc;
}

button.accordion:after {
content: '\002B';
color: #777;
font-weight: đậm;
float: right;
margin-left: 5px;
}

button.accordion.active:after {
content: "\2212";
}

div.panel {
padding: 0 18px;
background-color: white;
max-height: 0;
overflow: hidden;
transition: max-height 0.2s ease-out;
}

.events-section {
cỡ chữ: 12px;
text-align: left;
color: #000000;
}
   




<đầu>
RUNNERS WORLD








<điều hướng="">




About Us


Welcome to the runners world page. It is here that you will find all essential information to get you started in running. You will find information on Events, Top Tips, along with several photos displaying the best techniques. I hope that you enjoy
the website, and it acts as some inspiration to get you into running!









Top Tips


These are my Top 5 Tips for getting into running, and getting on the road to a healthier lifestyle...





Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.





Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.





Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.






1 Câu trả lời

我编辑了你的问题 $(document).ready(function() {}); 缺少添加它现在你的代码正在运行我看不到任何问题

$(tài liệu).ready(hàm() {

var acc = document.getElementsByClassName("accordion");
var i;

for (i = 0; i < acc.length; i++) {
acc[i].onclick = function() {
this.classList.toggle("active");
var panel = this.nextElementSibling;
if (panel.style.maxHeight) {
panel.style.maxHeight = null;
} khác {
panel.style.maxHeight = panel.scrollHeight + "px";
}
}
}
});
* {
lề: 0;
đệm: 0;
}

thân hình {
lề: 0;
đệm: 0;
width: 100%;
background-color: #ffffff;
overflow: scroll;
overflow-x: hidden;
font-family: 'Arial', serif;
}

.menu {
width: 100% height: 65%;
float: right;
background-color: #ffffff;
}

.menu>menu-content {
width: 200px;
height: 65px;
float: right;
font-family: 'Arial', serif;
font-size: 20px;
font-weight: đậm;
letter-spacing: -0.05em;
vị trí: tương đối;
color: #ffffff;
}

.menu>menu-content>a {
color: #ffffff;
text-decoration: none;
}

.NavBar {
background-color: #000000;
list-style: không có;
căn chỉnh văn bản: ở giữa;
vertical-align: middle;
line-height: 100px;
width: 100%;
}

.NavBar>li {
hiển thị: khối nội tuyến;
padding-right: 50px;
font-size: 15px;
}

.NavBar>li>a {
text-decoration: none;
color: #ffffff;
}

.NavBar>li>a:hover {
color: #c5c5c5;
}

.banner>.banner-pic {
width: 100%;
hiển thị: khối;
}

.about-section {
font-size: 18px;
căn chỉnh văn bản: ở giữa;
color: #000000;
padding: 40px 70px 40px 70px;
}

.about-section>p {
font-size: 15px;
căn chỉnh văn bản: ở giữa;
margin-top: 20px;
}

.toptips-section {
font-size: 18px;
căn chỉnh văn bản: ở giữa;
color: #000000;
padding: 40px 70px 40px 70px;
}

.toptips-section>p {
font-size: 15px;
căn chỉnh văn bản: ở giữa;
margin-top: 20px;
}

button.accordion {
background-color: #eee;
color: #444;
cursor: pointer;
padding: 18px;
width: 100%;
border: none;
text-align: left;
outline: none;
font-size: 15px;
transition: 0.4s;
}

button.accordion.active,
button.accordion:hover {
background-color: #ccc;
}

button.accordion:after {
content: '\002B';
color: #777;
font-weight: đậm;
float: right;
margin-left: 5px;
}

button.accordion.active:after {
content: "\2212";
}

div.panel {
padding: 0 18px;
background-color: white;
max-height: 0;
overflow: hidden;
transition: max-height 0.2s ease-out;
}

.events-section {
cỡ chữ: 12px;
text-align: left;
color: #000000;
}
   




<đầu>
RUNNERS WORLD








<điều hướng="">




About Us


Welcome to the runners world page. It is here that you will find all essential information to get you started in running. You will find information on Events, Top Tips, along with several photos displaying the best techniques. I hope that you enjoy
the website, and it acts as some inspiration to get you into running!









Top Tips


These are my Top 5 Tips for getting into running, and getting on the road to a healthier lifestyle...





Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.





Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.





Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.






关于javascript - 外部 jQuery 文件似乎没有执行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46835304/

26 4 0
Bài viết được đề xuất: php - 根据数据库字段内容自动(不是悬停)css 覆盖
Bài viết được đề xuất: c++ - "Most Important Const"再次
Bài viết được đề xuất: C++ 什么时候值得前向声明?
Bài viết được đề xuất: javascript - 客户端页面调用/抓取?
行者123
Hồ sơ cá nhân

Tôi là một lập trình viên xuất sắc, rất giỏi!

Nhận phiếu giảm giá Didi Taxi miễn phí
Mã giảm giá Didi Taxi
Giấy chứng nhận ICP Bắc Kinh số 000000
Hợp tác quảng cáo: 1813099741@qq.com 6ren.com