What is html function in jquery

What is html function in jquery

  • jQuery addClass() Method
  • jQuery after() Method
  • jQuery append() Method
  • jQuery appendTo() Method
  • jQuery attr() Method
  • jQuery before() Method
  • jQuery clone() Method
  • jQuery css() Method
  • jQuery detach() Method
  • jQuery empty() Method
  • jQuery hasClass() Method
  • jQuery height() and innerHeight() Methods
  • jQuery html() Method
  • jQuery innerWidth() Method
  • jQuery HTML/CSS Methods Complete Reference

jQuery Traversing

  • jQuery add() method
  • jQuery addBack() Method
  • jQuery | andSelf( ) with Examples
  • jQuery children() Method
  • jQuery closest() Method
  • jQuery contents() Method
  • jQuery eq() Method
  • jQuery filter() Method
  • jQuery find() Method
  • jQuery first() Method
  • jQuery has() Method
  • jQuery is() Method
  • jQuery last() Method
  • JQuery map() Method
  • jQuery Traversing Complete Reference

jQuery AJAX

  • jQuery ajax() Method
  • jQuery ajaxComplete() Method
  • jQuery ajaxError() Method
  • jQuery ajaxSend() Method
  • jQuery ajaxSetup() Method
  • jQuery ajaxStart() Method
  • jQuery ajaxStop() Method
  • jQuery ajaxSuccess() Method
  • jQuery | get() Method
  • jQuery getJSON() Method
  • JQuery | parseJSON() method
  • jQuery getScript() Method
  • jQuery param() method
  • jQuery | post() Method
  • jQuery AJAX Complete Reference

jQuery Properties

jQuery Plugins

  • jQuery Timepicker Plugin
  • jQuery bootstrapSelect Plugin
  • JavaScript ScrollLoopMenu Plugin
  • JavaScript Gallery Plugin
  • JavaScript RapidLayersAnimation Plugin
  • CSS Stacking Page Plugin
  • jQuery Image ProgressBars Plugin
  • jQuery jTippy Tooltip Plugin
  • jQuery hc-offcanvas-nav Plugin
  • jQuery Jcrop Plugin
  • jQuery Highcharts Plugin
  • jQuery GMaps Plugin
  • jQuery Plugins Complete Reference
Читайте также:  Java string utf 8 getbytes

jQuery Mobile

jQuery Interview Questions & Answers

  • jQuery Interview Questions and Answers
  • jQuery Interview Questions and Answers | Set-2
  • jQuery Interview Questions and Answers | Set-3
  • How to check if an element is hidden in jQuery?
  • How to check whether a checkbox is checked in jQuery?
  • How to know which radio button is selected using jQuery?
  • How to refresh a page using jQuery?
  • What is the correct JSON content type ?
  • How to convert jQuery to JavaScript ?
  • How to create UI Datepicker using jQuery ?
  • How to check a string starts/ends with a specific string in jQuery ?
  • How to convert first letter of a string to upper case using jQuery ?
  • How to select an element with multiple classes using jQuery ?
  • jQuery Examples

jQuery Selectors

  • jQuery * Selector
  • jQuery #id Selector
  • JQuery Multiple ID selectors
  • jQuery .class Selector
  • jQuery multiple classes Selector
  • jQuery element Selector
  • jQuery multiple elements Selector
  • jQuery :first Selector
  • jQuery :last Selector
  • jQuery :even Selector
  • jQuery :odd Selector
  • jQuery :first-child Selector
  • jQuery :first-of-type Selector
  • jQuery :last-child Selector
  • jQuery Selectors Complete Reference

jQuery Events

  • jQuery bind() method
  • jQuery blur() Method
  • jQuery change() Method
  • jQuery click() Method
  • jQuery dblclick() Method
  • jQuery delegate() Method
  • jQuery | die() Method
  • jQuery error() Method
  • jQuery event.currentTarget Property
  • jQuery event.data Property
  • jQuery event.delegateTarget Property
  • jQuery event.isDefaultPrevented() Method
  • jQuery event.isImmediatePropagationStopped() Method
  • jQuery event.isPropagationStopped() Method
  • jQuery Event Methods Complete Reference

jQuery Effect

  • jQuery animate() Method
  • jQuery clearQueue() Method
  • jQuery delay() Method
  • jQuery dequeue() Method
  • jQuery fadeIn() Method
  • jQuery Effect fadeOut() Method
  • jQuery fadeTo() Method
  • jQuery fadeToggle() Method
  • jQuery finish() Method
  • jQuery hide() Method
  • jQuery queue() Method
  • jQuery Effect show() Method
  • jQuery | slideDown() Method
  • jQuery | slideToggle() Method
  • jQuery Effects Complete Reference
  • jQuery addClass() Method
  • jQuery after() Method
  • jQuery append() Method
  • jQuery appendTo() Method
  • jQuery attr() Method
  • jQuery before() Method
  • jQuery clone() Method
  • jQuery css() Method
  • jQuery detach() Method
  • jQuery empty() Method
  • jQuery hasClass() Method
  • jQuery height() and innerHeight() Methods
  • jQuery html() Method
  • jQuery innerWidth() Method
  • jQuery HTML/CSS Methods Complete Reference
Читайте также:  Css table data center

jQuery Traversing

  • jQuery add() method
  • jQuery addBack() Method
  • jQuery | andSelf( ) with Examples
  • jQuery children() Method
  • jQuery closest() Method
  • jQuery contents() Method
  • jQuery eq() Method
  • jQuery filter() Method
  • jQuery find() Method
  • jQuery first() Method
  • jQuery has() Method
  • jQuery is() Method
  • jQuery last() Method
  • JQuery map() Method
  • jQuery Traversing Complete Reference

jQuery AJAX

  • jQuery ajax() Method
  • jQuery ajaxComplete() Method
  • jQuery ajaxError() Method
  • jQuery ajaxSend() Method
  • jQuery ajaxSetup() Method
  • jQuery ajaxStart() Method
  • jQuery ajaxStop() Method
  • jQuery ajaxSuccess() Method
  • jQuery | get() Method
  • jQuery getJSON() Method
  • JQuery | parseJSON() method
  • jQuery getScript() Method
  • jQuery param() method
  • jQuery | post() Method
  • jQuery AJAX Complete Reference

jQuery Properties

jQuery Plugins

  • jQuery Timepicker Plugin
  • jQuery bootstrapSelect Plugin
  • JavaScript ScrollLoopMenu Plugin
  • JavaScript Gallery Plugin
  • JavaScript RapidLayersAnimation Plugin
  • CSS Stacking Page Plugin
  • jQuery Image ProgressBars Plugin
  • jQuery jTippy Tooltip Plugin
  • jQuery hc-offcanvas-nav Plugin
  • jQuery Jcrop Plugin
  • jQuery Highcharts Plugin
  • jQuery GMaps Plugin
  • jQuery Plugins Complete Reference

jQuery Mobile

jQuery Interview Questions & Answers

  • jQuery Interview Questions and Answers
  • jQuery Interview Questions and Answers | Set-2
  • jQuery Interview Questions and Answers | Set-3
  • How to check if an element is hidden in jQuery?
  • How to check whether a checkbox is checked in jQuery?
  • How to know which radio button is selected using jQuery?
  • How to refresh a page using jQuery?
  • What is the correct JSON content type ?
  • How to convert jQuery to JavaScript ?
  • How to create UI Datepicker using jQuery ?
  • How to check a string starts/ends with a specific string in jQuery ?
  • How to convert first letter of a string to upper case using jQuery ?
  • How to select an element with multiple classes using jQuery ?
  • jQuery Examples
Читайте также:  Buffer reader in java

Источник

.html()

Get the HTML contents of the first element in the set of matched elements or set the HTML contents of every matched element.

.html() Возвращает: String

Описание: Get the HTML contents of the first element in the set of matched elements.

Добавлен в версии: 1.0 .html()

This method is not available on XML documents.

In an HTML document, .html() can be used to get the contents of any element. If the selector expression matches more than one element, only the first match will have its HTML content returned. Consider this code:

In order for the following ‘s content to be retrieved, it would have to be the first one with class=»demo-container» in the document:

div class="demo-container">
div class="demo-box">Demonstration Box div>
div>

The result would look like this:

div class="demo-box">Demonstration Box div>

This method uses the browser’s innerHTML property. Some browsers may not return HTML that exactly replicates the HTML source in an original document. For example, Internet Explorer sometimes leaves off the quotes around attribute values if they contain only alphanumeric characters.

Дополнительные замечания:

  • By design, any jQuery constructor or method that accepts an HTML string — jQuery(), .append(), .after(), etc. — can potentially execute code. This can occur by injection of script tags or use of HTML attributes that execute code (for example, ). Do not use these methods to insert strings obtained from untrusted sources such as URL query parameters, cookies, or form inputs. Doing so can introduce cross-site-scripting (XSS) vulnerabilities. Remove or escape any user input before adding content to the document.

.html( htmlString ) Возвращает: jQuery

Описание: Set the HTML contents of each element in the set of matched elements.

Добавлен в версии: 1.0 .html( htmlString )

Добавлен в версии: 1.4 .html( function )

A function returning the HTML content to set. Receives the index position of the element in the set and the old HTML value as arguments. jQuery empties the element before calling the function; use the oldhtml argument to reference the previous content. Within the function, this refers to the current element in the set.

The .html() method is not available in XML documents.

When .html() is used to set an element’s content, any content that was in that element is completely replaced by the new content. Additionally, jQuery removes other constructs such as data and event handlers from child elements before replacing those elements with the new content.

Consider the following HTML:

div class="demo-container">
div class="demo-box">Demonstration Box div>
div>

The content of can be set like this:

$( "div.demo-container" )
.html( "

All new content. You bet!

"
);

That line of code will replace everything inside :

div class="demo-container">
p>All new content. em>You bet! em> p>
div>

As of jQuery 1.4, the .html() method allows the HTML content to be set by passing in a function.

$( "div.demo-container" ).html(function()
var emphasis = "" + $( "p" ).length + " paragraphs!";
return "

All new content for " + emphasis + "

"
;
>);

Given a document with six paragraphs, this example will set the HTML of to

All new content for 6 paragraphs!

.

This method uses the browser's innerHTML property. Some browsers may not generate a DOM that exactly replicates the HTML source provided. For example, Internet Explorer prior to version 8 will convert all href properties on links to absolute URLs, and Internet Explorer prior to version 9 will not correctly handle HTML5 elements without the addition of a separate compatibility layer.

To set the content of a element, which does not contain HTML, use the .text() method and not .html() .

Note: In Internet Explorer up to and including version 9, setting the text content of an HTML element may corrupt the text nodes of its children that are being removed from the document as a result of the operation. If you are keeping references to these DOM elements and need them to be unchanged, use .empty().html( string ) instead of .html(string) so that the elements are removed from the document before the new string is assigned to the element.

Источник

Оцените статью