我有一个 div,它的内容应该改变(从另一个 div 的内容),并根据按钮翻转点击 这里是我的代码
<script type="text/javascript" src="../script/jquery-1.9.1.js"></script>
<script type="text/javascript" src="../jqueryflippy/jquery.flippy.min.js"></script>
<style>
html,body{
margin:0px;
padding:0px;
height:100%;
width:100%;
overflow:hidden;
background: #757575; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzc1NzU3NSIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM3MDcwNzAiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, #757575 0%, #707070 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#757575), color-stop(100%,#707070)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #757575 0%,#707070 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #757575 0%,#707070 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #757575 0%,#707070 100%); /* IE10+ */
background: linear-gradient(to bottom, #757575 0%,#707070 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#757575', endColorstr='#707070',GradientType=0 ); /* IE6-8 */
}
.content{
position:relative;
top:30%;
left:20%;
height:40%;
width:60%;
border: 1px solid #ffffff;
}
.contentTitle{
height:15%;
width:100%;
color:#ffffff;
font-size:15px;
font-weight:bold;
background: #2d2d2d; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iIzJkMmQyZCIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiM3ZDdlN2QiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, #2d2d2d 0%, #7d7e7d 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#2d2d2d), color-stop(100%,#7d7e7d)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #2d2d2d 0%,#7d7e7d 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #2d2d2d 0%,#7d7e7d 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #2d2d2d 0%,#7d7e7d 100%); /* IE10+ */
background: linear-gradient(to bottom, #2d2d2d 0%,#7d7e7d 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#2d2d2d', endColorstr='#7d7e7d',GradientType=0 ); /* IE6-8 */
}
.contentBody{
height:85%;
width:100%;
background: #ffffff; /* Old browsers */
/* IE9 SVG, needs conditional override of 'filter' to 'none' */
background: url(data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiA/Pgo8c3ZnIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIgdmlld0JveD0iMCAwIDEgMSIgcHJlc2VydmVBc3BlY3RSYXRpbz0ibm9uZSI+CiAgPGxpbmVhckdyYWRpZW50IGlkPSJncmFkLXVjZ2ctZ2VuZXJhdGVkIiBncmFkaWVudFVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgeDE9IjAlIiB5MT0iMCUiIHgyPSIwJSIgeTI9IjEwMCUiPgogICAgPHN0b3Agb2Zmc2V0PSIwJSIgc3RvcC1jb2xvcj0iI2ZmZmZmZiIgc3RvcC1vcGFjaXR5PSIxIi8+CiAgICA8c3RvcCBvZmZzZXQ9IjEwMCUiIHN0b3AtY29sb3I9IiNlNWU1ZTUiIHN0b3Atb3BhY2l0eT0iMSIvPgogIDwvbGluZWFyR3JhZGllbnQ+CiAgPHJlY3QgeD0iMCIgeT0iMCIgd2lkdGg9IjEiIGhlaWdodD0iMSIgZmlsbD0idXJsKCNncmFkLXVjZ2ctZ2VuZXJhdGVkKSIgLz4KPC9zdmc+);
background: -moz-linear-gradient(top, #ffffff 0%, #e5e5e5 100%); /* FF3.6+ */
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%,#ffffff), color-stop(100%,#e5e5e5)); /* Chrome,Safari4+ */
background: -webkit-linear-gradient(top, #ffffff 0%,#e5e5e5 100%); /* Chrome10+,Safari5.1+ */
background: -o-linear-gradient(top, #ffffff 0%,#e5e5e5 100%); /* Opera 11.10+ */
background: -ms-linear-gradient(top, #ffffff 0%,#e5e5e5 100%); /* IE10+ */
background: linear-gradient(to bottom, #ffffff 0%,#e5e5e5 100%); /* W3C */
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#ffffff', endColorstr='#e5e5e5',GradientType=0 ); /* IE6-8 */
}
</style>
<script>
$(function(){
$("#content").hide();
$("#content").animate({opacity:"show"},2000);
});
function rotate(divId){
alert(divId);
$(".content").flippy({
content : $('#'+divId).clone(true, true),
direction : "TOP",
duration : "2000",
onStart : function() {
//alert("Let's flip");
},
onFinish : function() {
//alert("ok, it's flipped :)");
}
});
}
</script>
</head>
<body>
<div class="content" id="div1">
<div class="contentTitle">
<div style="padding:1% 0 0 0;">div1 Details</div>
</div>
<div class="contentBody">
<input type="button" value="Test" onclick="rotate('div2')"/>
</div>
</div>
<div class="content" id="div2" style="visibility:hidden;">
<div class="contentTitle">
<div style="padding:1% 0 0 0;">div2 Details</div>
</div>
<div class="contentBody">
<input type="button" value="Test" onclick="rotate('div3')"/>
</div>
</div>
<div class="content" id="div3" style="visibility:hidden;">
<div class="contentTitle">
<div style="padding:1% 0 0 0;">div3 Details</div>
</div>
<div class="contentBody">
<input type="button" value="Test" onclick="rotate('div1')"/>
</div>
</div>
</body>
</html>
但是在第一次翻转(它工作正常)之后,按钮单击给出了相同的 div 内容(即 div2)。我已经坚持了一天,非常感谢任何帮助。