What is html() method?

 Posted by Rajnilari2015 on 12/19/2015 | Category: jQuery Interview questions | Views: 924 | Points: 40
Answer:

html(content) method replaces the contents of the element
e.g.
<!DOCTYPE html>

<html>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script>
$(document).ready(function(){
$('#btn1').click(function(){
$('#myspan').html('This is a <i>italic text</i>.This is another <i>italic text</i>.');
});
});
</script>
</head>
<body>
<button id="btn1">Exampleof html(Content)</button>

<span id="myspan">This is a <b>bold text</b>.This is another <b>bold text</b>.</span>

</body>
</html>


When we click on the "Exampleof html(Content)" button , the output becomes
<span id="myspan">This is a <i>italic text</i>.This is another <i>italic text</i>.</span>

This indicates that the inner html content of the span tag has been replaced .


Asked In: Many Interviews | Alert Moderator 

Comments or Responses

Posted by: Margaretrmartin on: 12/29/2015 | Points: 10
In HTML, one can specify two different submission methods for a form. The method is specified inside a FORM element, using the METHOD attribute. The difference between METHOD="GET" (the default) and METHOD="POST" is primarily defined in terms of form data encoding.

http://buyessays.us

Login to post response