+ 8
Why we cannot get output plz see this and fix it plz
13 Answers
+ 7
https://code.sololearn.com/WENOe6YY1Bcq/?ref=app
Here,
I'hv fixed it.
Check it out.
+ 6
The next one you posted will work,
because of that is internel script.
When you add JS inside <script>...</script>
You don't have to declare function;
Because of that will executed automatically.
But When you add JS in another file,
You have to declare function.
and to make sure that code run when webpage load,
Use "window.onload=fucti..."
+ 5
You have to declare function in the JS Script.
Wait till.
I'm fixing your code.
+ 4
You haven't declared Function(); 😁
+ 4
Welcome Brother 😊
+ 3
but
see this
<!DOCTYPE html>
<html>
<body>
<h2>The += Operator</h2>
<p id="demo"></p>
<script>
var x = 10;
x += 5;
document.getElementById("demo").innerHTML = x;
</script>
</body>
</html>
+ 3
run this code
+ 3
ooo thx bro
+ 3
oohk
+ 2
but how can we set function in paragraph tag
+ 2
thx
+ 2
thx fr answer to all
+ 1
Because you're trying to change an element that isn't loaded yet. That means you don't have any element with "demo" id, but you're trying to change it.
How to fix it?
1- Use jQuery:
$(document).ready(function () {
// Codes
});
2- Use onload attribute or event:
https://www.w3schools.com/jsref/event_onload.asp