0

I want to create element script inside tag script. I have error line 2. Thanks you sir.

create element script. https://code.sololearn.com/WuT04DCdKzYL/?ref=app

24th Jul 2021, 2:11 PM
Malick Diagne
Malick Diagne - avatar
2 Respostas
+ 1
It should be set to a src script.src = "../src/moment.min.js";
24th Jul 2021, 11:27 PM
Calviղ
Calviղ - avatar
+ 1
Malick Diagne Any reasons why do you want to write all the html and css codes in Javascript form only? For your script tag that formed by JavaScript, even though you manage to get to script setup by JavaScript, you can't manage to call the script function immediately, you would need onload script element to do it. For example if you use it to set moment.js script.src = "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.29.1/moment.min.js"; You cannot call moment function such as console.log(moment().format("LLL")); immediately. https://code.sololearn.com/WBl8ma4RxN98/?ref=app Writing all web codes without html and css is a bad practice, you should try to avoid it. If you pefer manipulate html element using JavaScript only, you can learn React.js, yet you still need to write html codes and css styles in jsx, however jsx allows JavaScript react codes directly interact with the its html and css codes. Check out some simple React Hook, please visit https://reactjs.org/docs/hooks
24th Jul 2021, 11:35 PM
Calviղ
Calviղ - avatar