求大神指正
<!DOCTYPE html>
<html lang="en">
<head>
? ?<meta charset="UTF-8">
? ?<title>Title</title>
? ?<link rel="stylesheet" href="/Public/css/bootstrap.min.css">
</head>
<body>
? ?<ul>
? ? ? ?<li>測試內容</li>
? ? ? ?<li>測試內容</li>
? ? ? ?<li>測試內容</li>
? ? ? ?<li>測試內容</li>
? ? ? ?<li>測試內容</li>
? ? ? ?<li>測試內容</li>
? ? ? ?<li>測試內容</li>
? ? ? ?<li>測試內容</li>
? ? ? ?<li>測試內容</li>
? ? ? ?<li><a class="btn btn-primary" href="#">更多</a></li>
? ?</ul>
<script src="/Public/JS/jquery.min.js"></script>
<script>
? ?$(function(){
? ? ? ?$("li:gt(3):not(li:last)").hide();
? ? ? ?$("a").click(function(){
? ? ? ? ? ?if($("a").html == "更多"){
? ? ? ? ? ? ? ?$("li").show();
? ? ? ? ? ? ? ?$("a").html("簡化");
? ? ? ? ? ?}else{
? ? ? ? ? ? ? ?$("li:gt(3):not(li:last)").hide();
? ? ? ? ? ? ? ?$("a").html("更多");
? ? ? ? ? ?}
? ? ? ?})
? ?})
</script>
</body>
</html>
為什么點更多沒反應
2016-07-15
?if($("a").html == "更多")判斷語句出錯應該是html()