-
Object.style.property=new style;
Object.style.display="none"/"block";
Object.className="new name";
例如:con.style.backgroundColor="red";
backgroundColor
height
width
color
font
fontFamily
fontSize
查看全部 -
Object.innerHTML 用于獲取? 或? 替換HTML元素的內(nèi)容
查看全部 -
window.open('href','_blank','width=300,height=200,menubar=no,toolbar=no, status=no,scrollbars=yes')
mywin.close();關(guān)掉窗口
查看全部 -
alert()彈出消息提示框
confirm()彈出消息對話框,包括一個(gè)確定按鈕,一個(gè)取消按鈕
查看全部 -
document.write(mystr+mychar+"sssss"+"<br>"+" "+"ssss");
變量不用加“”,輸出固定值加“”
查看全部 -
if(判斷條件){
}
else if{
}
else{
}
查看全部 -
<script src="script.js"></script>引用外部JS文件
查看全部 -
document.geiElementById("id").style.color="blue"; 表示設(shè)置某個(gè)id顏色為藍(lán)色
查看全部 -
代碼好難
查看全部 -
function openWindow(){
?????var queren=confirm("確定打開嗎?");
?????if(queren==true){
????? ???var myweb=prompt("請輸入網(wǎng)址","http://idcbgp.cn");
?????????if(myweb!=null){
?????????????window.open(myweb,"_blank",'width=400,heigth=500,menubar=no,toolbar=no')
?????????}
?????????else{
???????? ????alert("再見");
?????????}
??????}?
}
查看全部 -
不是一定要獲取到id名,直接用也行,但document.getElementById()這個(gè)方法得記得,這個(gè)作業(yè)涉及前面未學(xué)過的方法--removeAttribute(),對于return(flase)和return(trun)一直不太理解。
查看全部 -
fun是函數(shù)
查看全部 -
window.open('','','') 打開窗口
查看全部 -
var a = prompt() 文本框提示框
查看全部 -
var a=confirm() 消息對話框
查看全部 -
alert() 輸出提示框
document.write() 輸出流
查看全部 -
第一種:輸出內(nèi)容用""括起,直接輸出""號(hào)內(nèi)的內(nèi)容。
第二種:通過變量,輸出內(nèi)容
第三種:輸出多項(xiàng)內(nèi)容,內(nèi)容之間用+號(hào)連接。
第四種:輸出HTML標(biāo)簽,并起作用,標(biāo)簽使用""括起來。
查看全部 -
document.write("hello");查看全部
-
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>函數(shù)調(diào)用</title>
? ?<script type="text/javascript">
? ? ? function contxt() //定義函數(shù)
? ? ? {
? ? ? ? ?alert("哈哈,調(diào)用函數(shù)了!");
? ? ? }
? ?</script>
</head>
<body>
? ?<form>
? ? ? <input type="button"? value="點(diǎn)擊我" onclick=" contxt()? " />??
? ?</form>
</body>
</html>
查看全部 -
<!DOCTYPE HTML>
<html>
? ? <head>
? ? ? ? <meta http-equiv="Content-Type" content="text/html; charset=gb18030">
? ? ? ? <title>插入js代碼</title>
? ? ? ? <script type="text/javascript">
? ? ? ? document.write("開啟JS之旅!");
? ? </script>
? ? </head>
? ? <body>
? ? </body>
</html>
查看全部 -
<!DOCTYPE HTML>
<html>?
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>熱身</title>
</head>
<body>
? <p id="p1">我是第一段文字</p>
? <p id="p2">我是第二段文字</p>
??
? <script type="text/javascript">
document.write("hello");
document.getElementById("p1").style.color="blue";
? </script>
</body>
</html>
查看全部 -
getElementById是一個(gè)document對象的方法,可以通過它來獲得指定id的html元素。
例如在頁面里表單元素你可以給它設(shè)置id值,或name值來區(qū)別同種類型的不同元素,當(dāng)你設(shè)置id document.getElementById("id")來得到這個(gè)元素,從而通過document.getElementById("id").value 得到元素的值。類似的方法還有document.getElementsByName("name")通過元素名稱獲得元素對象。document.getElementsByTagName("form")通過標(biāo)簽名稱獲得元素。
比如 <div id="test"></div>
document.getElementById("test") 就可以獲取到這個(gè)對象了
查看全部
舉報(bào)