不知道 你要的是不是这种效果 jquery.min.js文件不要忘了
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=Edge">
<title></title>
<meta charset="utf-8">
<script type="text/javascript" src="./jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var oldHeight=$("#box").height();
$("#box").css({height:"100px"});
$(".showa").click(function(){
if(parseInt($("#box").height())==oldHeight){
$("#box").animate({height:"100px"});
$(this).html("展开");
}else{
$("#box").animate({height:oldHeight});
$(this).html("收起");
}
});
});
</script>
</head>
<body>
<div id="box" style="background:#98bf21;width:300px;margin:6px;line-height:20px;text-overflow:ellipsis;
overflow:hidden">
jQuery is a fast, small, and feature-rich JavaScript library. It makes things like HTML document traversal and manipulation, event handling, animation, and Ajax much simpler with an easy-to-use API that works across a multitude of browsers. With a combination of versatility and extensibility, jQuery has changed the way that millions of people write JavaScript.
</div>
<a href="javascript:void(0)" class="showa">展开</a>
</body>
</html>
追问为什么把代码放在单独一个文件里没问题,但是放在wordpress 主题首页代码里就不行了?
追答你说的WordPress 我没接触过 如果出现你上面说的问题 那就需要你自己去找 是不是哪里有冲突什么的