簡體   English   中英

單擊更改邊框圖像

[英]Change border Image on Click

我試圖通過單擊單選按鈕來更改邊框圖像,並且正在執行以下操作:

<input type="radio" name="field" value="4" onclick="document.getElementbyId('pet').style.borderImage='url(http://ianon.info/pet_support/borders/pawprint.png) 120 round'"/>

我收到以下錯誤:

Uncaught TypeError: document.getElementbyId is not a function

為什么這對“ border”選項有效,但對“ borderImage”選項無效? 我想在onc​​lick上定義它,因為我在文檔的不同部分中定義的所有JS函數都無法識別。

錯別字。 document.getElementbyId應該是document.getElementById 注意函數名稱中的大寫字母。

可以將其定義為腳本中的函數,並使用“ getElementById”大寫字母表示函數名稱。

<script>
        function changeimg(){
 document.getElementById('pet').style.borderImage='url(http://ianon.info/pet_support/borders/pawprint.png) 120 round';
        }
       </script>

<body>
<input type="radio" name="field" value="4" onclick= changeimg()/>
</body>

你犯了一個拼寫錯誤,更改document.getElementbyIddocument.getElementById

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM