Javascript:我的Javascript代码不工作?
javascript : my javascript code not working ??
似乎一切都很好,但当我点击按钮时,我的下拉菜单不出现,我认为原因是javascript不工作!!样式文件在我的CSS文件夹,它的工作很好这是我的代码。
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" type="text/css" href="css/skin.css"/>
<title>Change Directory Content</title>
<script>
/* When the user clicks on the button,
toggle between hiding and showing the dropdown content */
function myFunction() {
document.getElementById("myDropdown").classList.toggle("show");
}
</script>
</head>
<body>
<%@include file="header.jsp" %>
<div id="wrapper">
<div id ="page">
<div id="content">
<div class="box">
<div class="dropdown">
<button onclick="myFunction()" class="dropbtn">Dropdown</button>
<div id="myDropdown" class="dropdown-content">
<a href="#home">Home</a>
<a href="#about">About</a>
<a href="#contact">Contact</a>
</div>
</div>
<!--End Div -->
<div class="dropdownL">
<button onclick="myFunction()" class="dropbtn">Dropdown</button>
<div id="myDropdown" class="dropdown-content">
<a href="#">Link 1</a>
<a href="#">Link 2</a>
<a href="#">Link 3</a>
</div>
</div>
</div>
</div>
</div>
<br class="clearfix"/>
</div>
<%@include file="footer.jsp" %>
</body>
</html>
有什么帮助吗?
如果你想使用jquery
在这里输入链接描述
<script>
/* When the user clicks on the button,
toggle between hiding and showing the dropdown content */
function myFunction(id) {
$(id).siblings(".dropdown-content").toggle('slow');
}
</script>
用下拉
相关文章:
- 在表单提交将DOM的一部分替换为分部之后,我应该将ajax成功绑定到什么来使我的javascript工作
- 我可以'不要让Javascript工作不正常
- 如何让我的html5功能不兼容警告使用javascript工作
- Excel Web Services 电子邮件 JavaScript 工作表
- 用于Google Fusion Table层的Javascript工作,但试图整理代码
- Bootstrap:如何附加一个类,并且仍然有BS Javascript工作
- JavaScript 工作队列
- JavaScript工作,直到我添加这个&&陈述
- 为什么不'在CasperJS中没有简单的JavaScript工作
- 如何"递归AJAX回调”;在JavaScript工作中
- 基本验证javascript工作不正常
- 需要帮助让这个字符串的Javascript工作
- HTML和JavaScript工作不正常
- 下拉菜单无法从CSS或Javascript工作
- 需要从erb生成一个非常特定的html来让javascript工作
- 如果javascript代码段未使用,它将阻止其他javascript工作
- 将内联事件处理程序移动到chrome扩展的javascript工作表
- 阻止其他Javascript工作的Javascript
- iframe阻止javascript工作
- 无法获取切换函数(JavaScript工作)