PHP(样品只):
<?php
$records = array(1,2,3,4,5,6,7);
?>
HTML:
<html>
<body>
<div id="more">
<button>More</button>
</div>
<div id="less" style="display: none;">
<div id="codes" style="border-top: 1px dotted #d0d0d0;">
<?php
for($i=0; $i<count($records); $i++) {
printf("$records[%d] = %d<br />",$i,$records[$i]);
}
?>
</div>
</div>
</body>
</html>
JS:
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready(function() {
var i = 1;
$('div#more button').click(function() {
$('div#less').toggle();
if (i) { $(this).html('Less'); i=0; } else { $(this).html('More'); i=1; }
});
});
</script>
P.S.不要忘记包含jQuery插件,否则这将无法工作。
编辑:在那里,它是jquery.min.js
演示小提琴:http://jsfiddle.net/fe9wv/
嗯...'ID =“5”'说,按照最新的JQuery释放.live功能已被弃用,? – elclanrs
哦,对不起。我忘记了ID。我需要所有的buttos是一个类的成员,但取决于点击的按钮,用户将看到不同的阵列 – user1477886
你想在哪里显示更多“细节”?你可以写更多或显示快照 –