Javascript 如何在单击文本时来回交换文本?

Javascript 如何在单击文本时来回交换文本?,javascript,jquery,html,css,text,Javascript,Jquery,Html,Css,Text,我需要的是通过单击将文本\uuuuuuuuuu(间隙)来回交换到Word。我不想要扣子。用户只需单击间隙的位置即可 我明白了,它确切地描述了我所需要的,特别是CSS-Only方式,但是当我在TryIt编辑器上尝试它时,它或者jQuery方式都不起作用 以下是CSS方法: </style> #example { position: relative; } #example-checkbox { display: none; } #example-checkbox:checke

我需要的是通过单击将文本
\uuuuuuuuuu
(间隙)来回交换到
Word
。我不想要扣子。用户只需单击间隙的位置即可

我明白了,它确切地描述了我所需要的,特别是CSS-Only方式,但是当我在TryIt编辑器上尝试它时,它或者jQuery方式都不起作用

以下是CSS方法:

</style>
#example {
 position: relative; 
} 
#example-checkbox {
 display: none;
} 
#example-checkbox:checked + #example:after {
 content: "Hide";
 position: absolute;
 top: 0;
 left: 0;
 right: 0;
 bottom: 0;
 background: white;
 }
</style>

<input id="example-checkbox" type="checkbox">
<label for="example" id="example">Show</label>

#范例{
位置:相对位置;
} 
#示例复选框{
显示:无;
} 
#示例复选框:选中+#示例:之后{
内容:“隐藏”;
位置:绝对位置;
排名:0;
左:0;
右:0;
底部:0;
背景:白色;
}
显示

这就是你所期望的吗

<input id="example-checkbox" type="checkbox">
<label for="example-checkbox" id="example">Show</label>


Show
标签的
for
属性必须包含复选框的id
#示例{
位置:相对位置;
}
#示例复选框{
显示:无;
}
#示例复选框:选中+#示例:之后{
内容:“隐藏”;
位置:绝对位置;
排名:0;
左:0;
右:0;
底部:0;
背景:白色;
}

显示
_____
参考:
但是要确保在css中选择与网站颜色相匹配的适当背景颜色。

这是符合您要求的代码


这是一段。单击下一个单词-\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu。

函数切换(){ var word=document.getElementById(“word”).innerHTML; if(字分割(“”).join(“”).trim().length==0){ document.getElementById(“word”).innerHTML=“word”; }否则{ document.getElementById(“word”).innerHTML=“\uuuuuuuuuuuuuuuuu”; } }
html的文本“\uuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuuu。应将其替换为
Show
<label id="example-five" for="example-five-checkbox">_____</label>