JavaScript Interview Question and Answer

Question:- Give a example of using jQuery and JavaScript respectively:
Answer:-
                  jQuery
                   $('body').css('background','#ccc');

                  JavaScript
                   function changBackground(color)
                   {
                   Document.body.style.background = color;
                   Onload="changeBackground('green');"


Question:- What is the DOM?
Answer:-   The DOM is a W3C (World Wide Web Consortium) standard.
                  The DOM defines a standard for accessing documents:
                  "Document Object Model (DOM) is a interface that allows programs and scripts to dynamically access and update the content,structure, and style of a document."

            The W3C DOM standard is separated into 3 different parts:
                   Core DOM - standard model for all document types
                   XML DOM - standard model for XML documents
                   HTML DOM - standard model for HTML documents

Note:- The HTML DOM is a standard for how to get, change, add, or delete HTML elements.

Question:- Difference between empty() method and remove() method.
Answer:- 
  • remove() - Removes the selected element (and its child elements)
  • empty() - Removes the child elements from the selected element



Comments

Popular posts from this blog

Bootstrap Breakpoints