in Technology by

Choose the correct JavaScript syntax to change the content of the following HTML code.

<p id="blogmepost">Blogmepost</p>

A) document.getElement(“blogmepost”).innerHTML=”I am a blogmepost”;

B) document.getElementById(“blogmepost”).innerHTML=”I am a blogmepost”;

C) document.getId(“blogmepost”)=”I am a blogmepost”;

D) document.getElementById(“blogmepost”).innerHTML=I am a blogmepost;

1 Answer

0 votes
by

document.getElementById(“blogmepost”).innerHTML=”I am a blogmepost”;

Explanation: The correct syntax to access the element is document.getElementById(“blogmepost”). Here we want to access the content written under that id, so we used .innerHTML to specify that and finally we replaced the content with whatever is written inside the quotes.

\linebreak

Related questions

0 votes
    Which of the following is the correct HTML syntax for adding background color? 1.

... /p> 4.

...
asked Jul 12, 2021 in Technology by JackTerrance
0 votes
    Which of the following is the correct syntax to display blogmepostsforblogmeposts in an alert box using ... ( blogmepostsforblogmeposts ); D. alert( blogmepostsforblogmeposts );...
asked Feb 27, 2021 in Technology by JackTerrance
0 votes
    What is not true in context of HTML tag ? O Table cell changes its width automatically based on content O We can ... table border is o Select the correct answer from above options...
asked Nov 30, 2021 in Education by JackTerrance
0 votes
    Which is the correct HTML syntax for adding a link to the image? 1. ... xyz.com/image”>...
asked Jul 12, 2021 in Education by JackTerrance
0 votes
    Which of the following is a way of embedding Client-side JavaScript code within HTML documents? (a) From ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
+1 vote
    Select the statement that has correct JavaScript syntax a)document.write("text") b)alert stop ; c)console.log("text");...
asked Oct 8, 2020 in Technology by JackTerrance
0 votes
    Closed. This question needs details or clarity. It is not currently accepting answers. Want to improve this ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 23, 2022 in Education by JackTerrance
0 votes
    3. The given HTML code have some syntax error rewrite the code Page Tititle This is the para tag cols Punjab ... for scroll the text Select the correct answer from above options...
asked Dec 10, 2021 in Education by JackTerrance
0 votes
    Select the statement that has correct JavaScript syntax 1. document.write("text") 2. alert stop ; 3. console.log("text");...
asked Feb 23, 2021 by JackTerrance
0 votes
    What is the HTML tag under which one can write the JavaScript code? A) B) C)
    What is the JavaScript code snippet to update the content of the timestamp element when the user clicks on ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Oct 23, 2021 in Education by JackTerrance
...