【发布时间】:2014-01-30 14:47:11
【问题描述】:
我有一个 div,里面有一个 p,上面写着“折叠它!”。当我单击 div 时,p 的文本变为“展开它”。当我第二次单击 div 时,我该如何做到这一点,它会变回“折叠”?
HTML:
<div id="fold">
<p id="fold_p">Fold it</p>
</div>
JQuery:
<script>
$(document).ready(function () {
$("#fold").click(function () {
$("#fold_p").text("Expand it");
} )
} );
</script>
另外,是否有可能使过渡淡化? 非常感谢任何帮助:)
【问题讨论】:
-
Button text toggle in jquery 的可能重复项
标签: jquery html text onclick click