楊侑宸Javascript與Python比較
CSS也可以in-line
以上javascript與html與css程式碼
<STYLE>BUTTON{COLOR:WHITE;BORDER-RADIUS:20PX;}H1{COLOR:WHITE;BACKGROUND-COLOR:BLACK;TEXT-ALIGN:CENTER;PADDING:5PX;}</STYLE>
<button onclick="ABC()">全球市場價值最大的銀行</button>
<button onclick="XYZ()">按鈕PUSH增加</button>
<button onclick="kill()">按鈕POP執行自訂函數kill</button>
<button onclick="kill_SHOW()">按鈕POP執行kill呼叫其他函數</button>
<P id="SHOW" style="BACKGROUND-COLOR:PINK; FONT-SIZE:24PX;"></P>
CSS也可以in-line
<script>
banks=['摩根大通','美國銀行','中國工商銀行','富國銀行','匯豐銀行','巴黎銀行'];
function ABC() {
let x = '';//定義字串x內容空白
for (let i in banks)//javascript for loop () python不需要
{ x += banks[i] + '<BR>';} //x後面加上banks[0]....<>
document.getElementById('SHOW').innerHTML = x;}
function XYZ(){
banks.push('三菱銀行') //加入push
let x = '';//定義字串x內容空白
let n = banks.length; //n儲存banks串列list的長度length
for (let i=0; i < n; i++)//javascript for loop () python不需要
{ x += banks[i] + '<BR>';} //x後面加上banks[0]....<>
document.getElementById('SHOW').innerHTML = x;
}
function kill(){banks.pop();}
function kill_SHOW(){banks.pop(); ABC();}
</script>
留言
張貼留言