csdn文章的显示与折叠,在编辑器中点击源视图:
1.添加自己的代码
<!-- 添加自己的代码-->
<DIV style="BORDER-RIGHT: 1px; BORDER-TOP: 1px; BORDER-LEFT: 1px; CURSOR: hand; BORDER-BOTTOM: 1px" onclick=toggle(this,'myContent')>+Code</DIV>
<SCRIPT type=text/javascript>
function toggle(obj,id){
var content = document.getElementById(id);
if(content.style.display == 'none'){
content.style.display = 'block';
obj.innerHTML = '-Code';
}else{
content.style.display = 'none';
obj.innerHTML = '+Code';
}
}
</SCRIPT>
2.给div添加id属性、style属性
<!-- 以下是文章内容,根据需要给div添加id属性、style属性 -->
<DIV class=highlighter id=myContent style="DISPLAY: none"> ... </div>
本文介绍如何在优快云博客中实现代码的显示与折叠效果,通过使用特定的HTML标签和JavaScript函数,可以方便地控制代码块的显示状态,提升阅读体验。
307

被折叠的 条评论
为什么被折叠?



