JavaScript | Sololearn: Learn to code for FREE!
¡Nuevo curso! ¡Todo programador debería aprender IA Generativa!
Prueba una lección gratuita
0

JavaScript

Bonjour Je me demande comment on intègre du JavaScript dans du html sans passer par le tag script mais avec un <Link> dans <head> comme avec le css ?

12th Dec 2018, 12:18 PM
Axelle
7 Respuestas
+ 4
Vous pouvez lier un fichier js externe comme ceci <script src="https://cdnjs.cloudflare.com/ajax/libs/prefixfree/1.0.7/prefixfree.min.js"></script><!-- Thanks Andrew G for introducing this library --> <script src="https://unpkg.com/babel-standalone@latest/babel.min.js"></script><!-- Thanks KrOW for the Babel library--> https://code.sololearn.com/WuNp8CN7AkAe/?ref=app
12th Dec 2018, 12:22 PM
Gordon
Gordon - avatar
+ 3
https://code.sololearn.com/WriFNOoR188j/?ref=app
12th Dec 2018, 12:42 PM
Gordon
Gordon - avatar
+ 2
Sorry I worry translator will translate wrongly so I need to use English, if you don't understand, I'll ask French such as //Zohir to help. The above is an example to demo how to retrieve the DOM successfully. In Vanilla JS, there are getElementById getElementsByTagName getElementsByClassName Note the s in Elements for the second and third methods, it means that the result is an array, and so you need to use numerical index [0],[1],..etc Because the code playground JS tab will run before <body>, you need to put the getElement inside window.onload For CSS, you can style with tag name, id or class name, if a group of element share same style, we use class name instead of id.
12th Dec 2018, 12:47 PM
Gordon
Gordon - avatar
+ 1
ok merci il faut bien sue le code js interagisse avec le code html pour mettre des conditoon par exemple, on intergre les elements html dans js avec les id comme css?
12th Dec 2018, 12:32 PM
Axelle
0
ok thank but i see that there is too document.getElementById in the code for put the id like the getElementByTagName, getElementByClassName.... so se can put an id too ?
12th Dec 2018, 1:00 PM
Axelle
0
thank’s😊
12th Dec 2018, 9:38 PM
Axelle