Reputation: 252
I have written a simple javascript code which is not working. It is very simple but I couldn't find any error. Share if you see an error.
<script>
function close() {
console.log("clicked");
}
</script>
<div>
<p onclick="close()" id="adve">SOme thing</p>
</div>
Upvotes: 2
Views: 47
Reputation: 4739
You can't use the function name close which is the in built function in js(Close). You may change the function name like this.
<div>
<p onclick="close1();" id="adve">SOme thing</p>
</div>
<script>
function close1() {
document.getElementById("adve").style.left = "100px";
}
</script>
Upvotes: 3
Reputation: 1827
You can not use close() as a function. although you can use Close()
function close() {
document.getElementById("adve").style.color = "yellow";
}
function Close(){
document.getElementById("demo").style.color = "yellow";
}
<p id="adve" onclick="close()">SOme thing</p>
<p id="demo" onclick="Close()">Click me to change my text color.</p>
Upvotes: 0