tig*_*den 2 html javascript sorting
我期待着使用由强尼list.js.在这里,在其示例中,我尝试使用与此处给出的相同的列表代码.我在我的代码文件中复制了HTML,CSS和JS部分.此外,我下载并保存了list.js
给定的并将其粘贴到与我的代码文件相同的目录中.我正在使用WAMP,当我打开页面时,搜索功能无法在线工作.该表不会动态更新,甚至在我单击sort by name
按钮时也不会更新.
有谁可以告诉可能是什么问题?谢谢 :)
<!DOCTYPE html>
<html>
<head>
<script src="list.js"></script><meta charset=utf-8 />
<title>Existing list</title>
</head>
<body>
<script>
var options = {
valueNames: [ 'name', 'born' ]
};
var userList = new List('users', options);
</script>
<style>
.list {
font-family:sans-serif;
margin:0;
padding:20px 0 0;
}
.list > li {
display:block;
background-color: #eee;
padding:10px;
box-shadow: inset 0 1px 0 #fff;
}
.avatar {
max-width: 150px;
}
img {
max-width: 100%;
}
h3 {
font-size: 16px;
margin:0 0 0.3rem;
font-weight: normal;
font-weight:bold;
}
p {
margin:0;
}
input {
border:solid 1px #ccc;
border-radius: 5px;
padding:7px 14px;
margin-bottom:10px
}
input:focus {
outline:none;
border-color:#aaa;
}
.sort {
padding:8px 30px;
border-radius: 6px;
border:none;
display:inline-block;
color:#fff;
text-decoration: none;
background-color: #28a8e0;
height:30px;
}
.sort:hover {
text-decoration: none;
background-color:#1b8aba;
}
.sort:focus {
outline:none;
}
.sort:after {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 5px solid transparent;
content:"";
position: relative;
top:-10px;
right:-5px;
}
.sort.asc:after {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-top: 5px solid #fff;
content:"";
position: relative;
top:13px;
right:-5px;
}
.sort.desc:after {
width: 0;
height: 0;
border-left: 5px solid transparent;
border-right: 5px solid transparent;
border-bottom: 5px solid #fff;
content:"";
position: relative;
top:-10px;
right:-5px;
}
</style>
<div id="users">
<input class="search" placeholder="Search" />
<button class="sort" data-sort="name">
Sort by name
</button>
<ul class="list">
<li>
<h3 class="name">Jonny Stromberg</h3>
<p class="born">1986</p>
</li>
<li>
<h3 class="name">Jonas Arnklint</h3>
<p class="born">1985</p>
</li>
<li>
<h3 class="name">Martina Elm</h3>
<p class="born">1986</p>
</li>
<li>
<h3 class="name">Gustaf Lindqvist</h3>
<p class="born">1983</p>
</li>
</ul>
</div>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
的Javascript
:
<script>
var options = {
valueNames: [ 'name', 'born' ]
};
var userList = new List('users', options);
</script>
Run Code Online (Sandbox Code Playgroud)
需要放在HTML
(在关闭体标签之前)下面,因为script
需要在之后运行html
.目前你有script
上面的html
- 所以它不知道标记存在.
归档时间: |
|
查看次数: |
3017 次 |
最近记录: |