我有一个面板代码窗格,显示此代码以显示/隐藏内容,如果一个字段,它工作得很好但我希望代码只是在%node中没有内容时显示任何内容:field_desc6
<script language="javascript">
function toggle() {
var ele = document.getElementById("toggleText");
var text = document.getElementById("displayText");
if(ele.style.display == "block") {
ele.style.display = "none";
text.innerHTML = "Show Non-CGD Publications";
}
else {
ele.style.display = "block";
text.innerHTML = "Hide Non-CGD Publications";
}
}
</script>
<a id="displayText" href="javascript:toggle();">Show Non-CGD Publications</a>
<div id="toggleText" style="display: none">%node:field_desc6</div>
答案 0 :(得分:0)
试试这个:
<script language="javascript">
function toggle() {
var ele = document.getElementById("toggleText");
var text = document.getElementById("displayText");
if(ele.style.display == "block") {
ele.style.display = "none";
text.innerHTML = "Show Non-CGD Publications";
}
else {
ele.style.display = "block";
text.innerHTML = ""; // here you don't put any text...
}
}
</script>
<a id="displayText" href="javascript:toggle();">Show Non-CGD Publications</a>
<div id="toggleText" style="display: none">%node:field_desc6</div>