3 回答

TA貢獻(xiàn)1785條經(jīng)驗(yàn) 獲得超8個(gè)贊
沒(méi)有看到您的代碼,很難提供任何反饋,但我可以提出一些建議。您可以使用 css 隱藏您的提示和解決方案 - 將顯示設(shè)置為無(wú)是最簡(jiǎn)單的。如果您只隱藏提示和解決方案,那么查看頁(yè)面源代碼或檢查元素的任何人都可以看到它們。您可以在標(biāo)記中寫(xiě)入一個(gè)空的提示和解決方案容器,然后在用戶與按鈕交互時(shí)添加提示和解決方案文本。使用 Javascript 或 jQuery,在您的點(diǎn)擊事件中,將提示或解決方案附加到 DOM 或設(shè)置元素的 innerHTML。
好的,我現(xiàn)在看到了你的示例代碼 - 你可以設(shè)置一個(gè)函數(shù)在加載時(shí)運(yùn)行并通過(guò) id 選擇你的元素并將其設(shè)置為不顯示。此頁(yè)面可以幫助您了解加載事件 - https://developer.mozilla.org/en-US/docs/Web/API/Window/load_event

TA貢獻(xiàn)1900條經(jīng)驗(yàn) 獲得超5個(gè)贊
在標(biāo)頭中使用 CSS(不是作為<link>
,但實(shí)際上是內(nèi)聯(lián)的)強(qiáng)制隱藏這些組件,然后使用 JavaScript 稍后顯示它們。
例子:
.my-secret-div { display:none; }
...
<div class="my-secret-div"> the hint goes here </div>
...
然后使用 Javascript 刪除my-secret-div
該類。
請(qǐng)注意,這不會(huì)向可以下載頁(yè)面或使用瀏覽器開(kāi)發(fā)人員工具“檢查”內(nèi)容的人隱藏內(nèi)容。
示例小提琴:https ://jsfiddle.net/5qnoghrf/

TA貢獻(xiàn)1829條經(jīng)驗(yàn) 獲得超7個(gè)贊
我想你的意思是隱藏 div 的內(nèi)容而不是按鈕,只需將你的項(xiàng)目設(shè)置為:style="display:none"內(nèi)聯(lián)。
function solution0() {
var x = document.getElementById("solution0");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
function hint0() {
var x = document.getElementById("hint0");
if (x.style.display === "none") {
x.style.display = "block";
} else {
x.style.display = "none";
}
}
<button onclick="hint0()">Hint</button>
<div id="hint0" style="display:none">
Try reading the man pages for some of the listed commands on the OverTheWire level page. They may be useful!
</div>
<button onclick="solution0()">Solution</button>
<div id="solution0" style="display:none">
You need to use cat to print the contents of the file "readme". The file contains the password that you can copy and paste to log in to bandit1.
</div>
添加回答
舉報(bào)