Uyisebenzisa kanjani i-GetElementById yeJavaScript ukufikelela kwindawo ethile

NguSteve Suehring, uJanet Valade

Ungasebenzisa iJavaScript ukufikelela kwindawo ethile kwiphepha le-HTML. Unokwenza oku ukwenza utshintsho kwinto okanye isitayile seCSS. Yizame kwimithambo.

ipilisi emhlophe ine 176 kuyo
  1. Vula umhleli wakho wokubhaliweyo ngoxwebhu olutsha okanye olungenanto.



    umfanekiso0.jpg

  2. Kumhleli wokubhaliweyo, beka le HTML kunye neJavaScript elandelayo:

     Chapter 2 Hello Second Line 

    This is in a paragraph.

    Last Line
  3. Gcina le fayile njenge-bybyid.html kwingcambu yoxwebhu lwakho.

    umfanekiso1.jpg

  4. Vula isikhangeli sakho sewebhu kwaye ujonge iphepha ku-http: // yobulali /okhupha.html.

    Kuya kufuneka ubone isilumkiso esifana nesiboniswe apha.

    umfanekiso2.jpg

  5. Cofa KULUNGILE ukugxotha isilumkiso kwaye uvale isikhangeli sakho.

  6. Buyela ngaphakathi kwe-bybyid.html kumhleli wakho, susa umgca weJavaScript oqala ngesilumkiso. Faka lo mgca endaweni yezi zimbini:

    theDiv.style.border = '3px solid black'; theDiv.innerHTML = 'This is now changed text.';

    Yonke ibhloko yeskripthi kufuneka ngoku ijongeke ngolu hlobo:

    Xa ujongwa kwisikhangeli, iphepha ngoku libonakala ngathi libonisiwe apha. Qaphela ngokukodwa ukuba isicatshulwa somgca ophezulu sitshintshiwe kwaye ngoku sinomda.

    umfanekiso3.jpg