1. Home
  2. Computer Science MCQs
  3. Jquery
  4. Which jQuery method is used to set the text content of an…

Added 30 Jan 2024

Which jQuery method is used to set the text content of an element?

  1. setText()
  2. text() Correct answer
  3. textContent()
  4. innerContent()

Correct answer

B. text()

16 views

MCQSEXAM

Explanation

text() sets or returns the text content of the selected elements. $("#msg").text("Hello") sets it; calling text() with no argument reads it.

Use html() when the content includes markup and val() for form fields. textContent is a plain JavaScript property, not a jQuery method.

Keep preparing with more Computer Science MCQs on MCQsExam.com.

Reference

https://www.w3schools.com/jquery/default.asp

Doubts & discussion

Not sure why the answer is B? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More Jquery MCQs

Practise all Jquery MCQs

Similar MCQs