我正在尝试在点击时换出按钮文本。按钮的功能是切换<div>
。使用jQuery可以设置按钮文本的两个实例,并在切换时将它们交换出来吗?
这就是我到目前为止所处的位置:
$('#showmodule').click(function() {
$(this).addClass('active');
$('#module').slideToggle()
});
发布于 2012-05-04 12:31:13
在你的例子中,我会做的是在你的锚链接中添加跨度,并切换它们,如下所示。
<a href="#" id="showmodule">
<span>Default Text</span>
<span style="display : none;">Toggled Text</span>
</a>
javascript应该看起来像这样。
$('#showmodule').click(function() {
$(this).addClass('active');
$('span', this).toggle(); // This line will toggle the spans inside of the link
$('#module').slideToggle()
});
https://stackoverflow.com/questions/10442710
复制相似问题