1
這工作與onclick
屬性:用JavaScript onclick屬性的作品,但不是如果等效函數被調用
<button type="button" onclick="this.style.color='red';">Astringents</button>
此作品在onclick屬性,但如果從頭部元素稱爲:
<head>
<script type="text/javascript">
function red() {
this.style.color='red';
}
</script>
</head>
<button type="button" onclick="red();">Astringents</button>
編輯:我想用一個函數來服務幾個按鈕。例如:
<button type="button" onclick="red();">Astringents</button>
<button type="button" onclick="red();">Exfoliators</button>
<button type="button" onclick="red();">Moisturizers</button>
<button type="button" onclick="red();">Masques</button/>
感謝它的工作! – Corey 2011-02-16 04:22:23