JQuery è una libreria Javascript che semplifica codice lato client interazioni con pagine Web. JQuery consente di selezionare facilmente i singoli tag e gli elementi in una pagina Web e modificare le loro proprietà istantaneamente con un breve comando. Utilizzando jQuery, è possibile modificare il testo HTML in una pagina Web selezionando l'elemento e sostituendo il testo HTML.
Istruzioni
1
Creare una pagina HTML e includere la libreria jQuery dal sito di Google pubblicamente hosting. Ad esempio, digitare:
<! DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional / / EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd" >
< html xmlns = "http://www.w3.org/1999/xhtml" >
< head >
< meta http-equiv = "Content-Type" content = "text/html; charset = utf-8 "/ >
< title > Baby Link < / title >
< script type = "text/javascript" tag e utilizzare il metodo di "html" per sostituire il codice HTML. Ad esempio, digitare:
< script type = "text/javascript" >
Web {
var rand = Math. Floor (Math. Random () * 10) + 1;
Se (rand %2 = = 0)
$("#type").html("boy ");
altro
$("#type").html("girl");
});
< / script >
< / head >
3
Creare il corpo della pagina HTML. Includere il "id" a cui fa riferimento la funzione Javascript in cui viene sostituito il codice HTML. Ad esempio, digitare:
< corpo >
È un < un href="baby.html" id = "tipo" >< /a >!
< / body >
< / html >