課程
/前端開發(fā)
/JavaScript
/JavaScript入門篇
reset函數(shù)運行不了,是什么鬼?????
2018-10-26
源自:JavaScript入門篇 4-1
正在回答
reset是關(guān)鍵字,不能用否則有沖突,你可以改成其他名字,這種簡單而且涉及操作的英文如果出問題了,實在找不到原因基本上都可以注意一下是不是關(guān)鍵字沖突。
改一下函數(shù)名就可以了,不能用reset,會有沖突的。
其他的都能用就reset不行
<input type="button" onclick="changecolor()" value="改變顏色" >??
? ? <input type="button" onclick="changewidth()" value="改變寬高" >
? ? <input type="button" onclick="content()" value="隱藏內(nèi)容" >
? ? <input type="button" onclick="display()" value="顯示內(nèi)容" >
? ? <input type="button" onclick="reset()" value="取消設(shè)置" >
? </form>
? <script type="text/javascript">
? ? var text=document.getElementById('con');
? ? var box=document.getElementById('txt');
? ? function changecolor(){
? ? ? ? text.style.color='red';
? ? ? ? box.style.backgroundColor='gray';
? ? }
? ? function changewidth(){
? ? ? ? var box=document.getElementById('txt');
? ? ? ? box.style.width='200px';
? ? ? ? box.style.height='500px';
? function content(){
? ? ? box.style.display="none";
? }
? function display(){
? ? ? box.style.display="block";
? ? function reset(){
? ? ? ? var srs = confirm("確認取消設(shè)置?");
? ? ? ? if (srs==true)
? ? ? ? {
? ? ? ? ? ? box.style.color = "black";
? ? ? ? ? ? box.style.backgroundColor = "white";
? ? ? ? ? ? box.style.width = orignWidth;
? ? ? ? ? ? box.style.height = orignHeight;
? ? ? ? ? ? box.style.display = "block";
? ? ? ? }
? </script>
</body>
</html>
舉報
JavaScript做為一名Web工程師的必備技術(shù),本教程讓您快速入門
2 回答reset函數(shù)不運行,求解
5 回答函數(shù)運行不了
1 回答reset不能為函數(shù)名嗎?
3 回答為什么將取消設(shè)置的函數(shù)起名為 reset 就不行呢?
1 回答reset不行,好像reset是關(guān)鍵詞
Copyright ? 2025 imooc.com All Rights Reserved | 京ICP備12003892號-11 京公網(wǎng)安備11010802030151號
購課補貼聯(lián)系客服咨詢優(yōu)惠詳情
慕課網(wǎng)APP您的移動學(xué)習伙伴
掃描二維碼關(guān)注慕課網(wǎng)微信公眾號
2018-11-01
reset是關(guān)鍵字,不能用否則有沖突,你可以改成其他名字,這種簡單而且涉及操作的英文如果出問題了,實在找不到原因基本上都可以注意一下是不是關(guān)鍵字沖突。
2018-10-26
2018-10-26
其他的都能用就reset不行
2018-10-26
<input type="button" onclick="changecolor()" value="改變顏色" >??
? ? <input type="button" onclick="changewidth()" value="改變寬高" >
? ? <input type="button" onclick="content()" value="隱藏內(nèi)容" >
? ? <input type="button" onclick="display()" value="顯示內(nèi)容" >
? ? <input type="button" onclick="reset()" value="取消設(shè)置" >
? </form>
? <script type="text/javascript">
? ? var text=document.getElementById('con');
? ? var box=document.getElementById('txt');
? ? function changecolor(){
? ? ? ? text.style.color='red';
? ? ? ? box.style.backgroundColor='gray';
? ? }
? ? function changewidth(){
? ? ? ? var box=document.getElementById('txt');
? ? ? ? box.style.width='200px';
? ? ? ? box.style.height='500px';
? ? }
? function content(){
? ? ? box.style.display="none";
? }
? function display(){
? ? ? box.style.display="block";
? }
? ? function reset(){
? ? ? ? var srs = confirm("確認取消設(shè)置?");
? ? ? ? if (srs==true)
? ? ? ? {
? ? ? ? ? ? box.style.color = "black";
? ? ? ? ? ? box.style.backgroundColor = "white";
? ? ? ? ? ? box.style.width = orignWidth;
? ? ? ? ? ? box.style.height = orignHeight;
? ? ? ? ? ? box.style.display = "block";
? ? ? ? }
? ? }
? </script>
</body>
</html>