Code: Select all
<p id="p1">Testing testing</p>
<script type="text/javascript">
document.getElementById("p1").onclick="this.style.backGroundColor='red' ";
</script>
Code: Select all
<p id="p1">Testing testing</p>
<script type="text/javascript">
document.getElementById("p1").onclick="this.style.backGroundColor='red' ";
</script>
Code: Select all
<p id="p1">Testing testing</p>
<script type="text/javascript">
var p1 = document.getElementById("p1");
p1.onclick=function() {
p1.style.background="red"
}
</script>
Code: Select all
window.onload = function () {
//insert your DOM-altering code here
}