<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<ul>
<li>aa</li>
<li>bb</li>
<li>cc</li>
<li>dd</li>
<li>ee</li>
</ul>
<script type="text/javascript">
var value=document.getElementsByTagName('li')[2].childNodes[0].nodeValue;
document.write(value);
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(0)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<ul>
<li>aa</li>
<li>bb</li>
<li>cc</li>
<li>dd</li>
<li>ee</li>
</ul>
<script type="text/javascript">
var value=document.getElementsByTagName('li')[2].childNodes[0].nodeValue;
document.write(value);
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(7)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<ul><li>aa</li><li>bb</li><li>cc</li><li>dd</li><li>ee</li></ul>
<script type="text/javascript">
var cc= document.getElementsByTagName('li')[2];
var ul=document.getElementsByTagName('ul')[0];
document.write('cc前一個是'+cc.previousSibling.textContent+'<br>');
document.write('cc後一個是'+cc.nextSibling.textContent+'<br>');
document.write('ul的第一個孩子是'+ul.firstChild.textContent+'<br>');
document.write('ul的最後一個孩子是'+ul.lastChild.textContent+'<br>');
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(0)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<ul><li>aa</li><li>bb</li><li>cc</li><li>dd</li><li>ee</li></ul>
<script type="text/javascript">
var cc= document.getElementsByTagName('li')[2];
var ul=document.getElementsByTagName('ul')[0];
document.write('cc前一個是'+cc.previousSibling.textContent+'<br>');
document.write('cc後一個是'+cc.nextSibling.textContent+'<br>');
document.write('ul的第一個孩子是'+ul.firstChild.textContent+'<br>');
document.write('ul的最後一個孩子是'+ul.lastChild.textContent+'<br>');
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(12)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<ul class="ulooo">
<li>11</li>
<li>22</li>
<li>33</li>
<li>44</li>
<li>55</li>
<li>66</li>
</ul>
<script type="text/javascript">
document.write('第一個被選到的是:'+document.querySelector('.ulooo li').textContent+'<br>');
document.write('總共被選到的數量:'+document.querySelectorAll('.ulooo li').length);
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(0)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<ul class="ulooo">
<li>11</li>
<li>22</li>
<li>33</li>
<li>44</li>
<li>55</li>
<li>66</li>
</ul>
<script type="text/javascript">
document.write('第一個被選到的是:'+document.querySelector('.ulooo li').textContent+'<br>');
document.write('總共被選到的數量:'+document.querySelectorAll('.ulooo li').length);
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(435)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
var i = 0;
do{
document.write('很重要所以要跑三次,已經跑了'+(i+1)+'次<br>');
i++;
}while(i<3);
if(i>=3){
document.write('三次結束囉');
}
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(9)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
var i = 0;
do{
document.write('很重要所以要跑三次,已經跑了'+(i+1)+'次<br>');
i++;
}while(i<3);
if(i>=3){
document.write('三次結束囉');
}
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(0)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
var i = 1;
while(i<10){
document.write('5x'+i+'='+i*5+'<br>');
i++;
}
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(9)
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<script type="text/javascript">
var i = 1;
while(i<10){
document.write('5x'+i+'='+i*5+'<br>');
i++;
}
</script>
</body>
</html>
Jerry 發表在 痞客邦 留言(0) 人氣(0)