寫完函數事件后,不要忘了回到input表單,設置鼠標點擊事件onclick="函數名"
<input type="button" value="改變顏色" onclick="tp()">
<input type="button" value="改變寬高" onclick="whchange()" >
<input type="button" value="隱藏內容" onclick="hidetext()">
<input type="button" value="顯示內容" onclick="showtext()" >
<input type="button" value="改變顏色" onclick="tp()">
<input type="button" value="改變寬高" onclick="whchange()" >
<input type="button" value="隱藏內容" onclick="hidetext()">
<input type="button" value="顯示內容" onclick="showtext()" >
//定義"隱藏內容"的函數
function hidetext()
{
var mychar= document.getElementById("txt");
mychar.style.display="none";
}
//定義"顯示內容"的函數
function showtext()
{
var mychar = document.getElementById("txt");
mychar.style.display="block";
}
function hidetext()
{
var mychar= document.getElementById("txt");
mychar.style.display="none";
}
//定義"顯示內容"的函數
function showtext()
{
var mychar = document.getElementById("txt");
mychar.style.display="block";
}
//定義"改變顏色"的函數
function tp(){var mychar = document.getElementById("txt");
mychar.style.color="red";
mychar.style.style.backgroundColor="#CCC";}
//定義"改變寬高"的函數
function whchange(){
var mychar= document.getElementById("txt");
mychar.style.width="350px";
mychar.style.height="300px";}
function tp(){var mychar = document.getElementById("txt");
mychar.style.color="red";
mychar.style.style.backgroundColor="#CCC";}
//定義"改變寬高"的函數
function whchange(){
var mychar= document.getElementById("txt");
mychar.style.width="350px";
mychar.style.height="300px";}
<script type="text/javascript">
function add(){
var p1 = document.getElementById("p1");
document.write("one"+p1.className+"<br>");}
function modify(){
var p2 = document.getElementById("p2");
p2.className="two";}
</script>
function add(){
var p1 = document.getElementById("p1");
document.write("one"+p1.className+"<br>");}
function modify(){
var p2 = document.getElementById("p2");
p2.className="two";}
</script>
2015-08-02
<script type="text/javascript">
function hidetext(){
var mychar = document.getElementById("con");
mychar.style.display=none;}
function showtext()
{var mychar = document.getElementById("con");
mychar.style.display:block;}
</scrip>
function hidetext(){
var mychar = document.getElementById("con");
mychar.style.display=none;}
function showtext()
{var mychar = document.getElementById("con");
mychar.style.display:block;}
</scrip>
2015-08-02
<script type="text/javascript">
var mychar=document.getElementById("con");
document.write("原標題:"+mychar.innerHTML+"<br>"); //輸出原h2標簽內容
mychar.innerHTML="Hello world!";
document.write("修改后的標題:"+mychar.innerHTML); //輸出修改后h2標簽內容
</script>
var mychar=document.getElementById("con");
document.write("原標題:"+mychar.innerHTML+"<br>"); //輸出原h2標簽內容
mychar.innerHTML="Hello world!";
document.write("修改后的標題:"+mychar.innerHTML); //輸出修改后h2標簽內容
</script>
2015-08-02
<script type="text/javascript">
function openWindow(){
var open=confirm("確認打開新窗口嗎?")
if(open=true)
{window.open('http://www.xianlaiwan.cn/','_blank','width=400,height=500,menubar=no,toolbar=no');}
else{mywin.close();}
}
function openWindow(){
var open=confirm("確認打開新窗口嗎?")
if(open=true)
{window.open('http://www.xianlaiwan.cn/','_blank','width=400,height=500,menubar=no,toolbar=no');}
else{mywin.close();}
}
function openWindow()
var open=confirm("確認打開新窗口嗎?")
if(open=true)
{ window.open('http://www.xianlaiwan.cn/','_blank','width=400,height=500,menubar=no,toolbar=no')}
else{mywin.close();}
var open=confirm("確認打開新窗口嗎?")
if(open=true)
{ window.open('http://www.xianlaiwan.cn/','_blank','width=400,height=500,menubar=no,toolbar=no')}
else{mywin.close();}