為啥沒效果呀
為什么沒效果呀?
?<input type="button" value="改變顏色" onclick="changeColor()"> ?
? ? <input type="button" value="改變寬高" onclick="changeSize()">
? ? <input type="button" value="隱藏內容" onclick="objHide()">
? ? <input type="button" value="顯示內容" onclick="objShow()">
? ? <input type="button" value="取消設置" onclick="offSet()">
? </form>
? <script type="text/javascript">
? var obj=document.getElementById("txt");
? function changeColor()
? {
? obj.style.color="blue";
? obj.style.backgroundColor="red";
? }
??
?function changeSize()
?{
?obj.style.width="300px";
? obj.style.height="500px";
? }
? function objHide()
? {
? obj.style.display="none";
? }
? ?function objShow()
? ?{
? obj.style.display="block";
? }
function offSet()
?{
? ?var mymessage=confirm("確定取消設置?");
? ?if(mymessage)
? ?{
? ? obj.removeAttribute('style');
? ? ? ? }
? ?}
2016-10-19
var mymessage=confirm("確定取消設置?");這里你使用的是非英文分號 改成英文的 就OK了
2016-10-19
你那個obj對象沒有具體賦值,也就是說你沒有取到具體的HTMLDOM 對象,他不知道去改變那個節點