javascript找對象與使用對象方法
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta http-equiv="X-UA-Compatible" content="ie=edge"> <title>找對象</title> </head> <body> <h4>標題</h4> <div id="test1"> <p>1</p> <p>2</p> <p>3</p> </div> <div class="test2" > test </div> username:<input type="text" name="username" value="Mark"> username:<input type="text" name="username2" value="Mark"> <script> //『用ID查詢』 //返回對象 ( objectHTMLElement ) console.log(document.getElementById("test1")); //操作方式 document.getElementById("test1").style.border