("") are the same When deleting the content in the matching element. JQuery source code has different implementations, but the effects are the same. You can test it.Source code: Why does jQuery no longer execute the following content after html code is output?
Alert ("ul" example .html ()This is an error.What do you mean by printing
Look at an example:
Copy Code code as follows:
var tbody=document.createelement (' tbody ');
The InnerHTML of Tbody.innerhtml= '
Now try the HTML in jquery,
Copy Code code as follows:
$ (tbody). html ('
The discovery of IE with jquery can be correctly displayed, there is
combined with the text content contained by all matching elements. The return is a string example: HTML page code: "P"). text (); Result: hellofinethankyou! 2. Parameter text (val): Sets the text content of all matching elements, similar to HTML (), but encodes HTML ( ">" is replaced with the corresponding HTML entity. Returns a jquery object HTML page code: "P"). Text ( " Finally, there are t
Set or get the value of the selection in *jquery:Text (); Sets or gets the textual content of the selected element;HTML (); Sets or gets the contents of the selected element (including HTML tags);Val (); Sets or gets the value of the form field (provided the form has the Value property set);(text () and HTML () the difference is that the former is the processing of text content, can only write text if the above markup is written in the form of text output, the latter can parse the text of the HT
selection in jquery:①text (); Sets or gets the text content of the selected element;②html (); Sets or gets the contents of the selected element (including HTML tags);③val (); Sets or gets the value of a form field (provided the form has the Value property set);First, there are two methods in the HTML attribute, one with an argument, one without 1. No parameter HTML (): Gets the HTML content of the first matching element. This function cannot be used
Example:
Copy codeThe Code is as follows: var tbody = document. createElement ('tbody ');
Tbody. innerHTML = 'Try jquery's html,Copy codeThe Code is as follows: Required (tbody).html ('
I found that jquery can be correctly displayed in IE, and there is no problem.Later, I found out that the tbody and tr innerHTML in
In the Ajax bar today, we have a higher demand for page interaction, dynamic generation of HTML is undoubtedly one of them. There are a variety of ways to generate HTML dynamically, the core of which is in the front (JS) or back-end (c#/php ...). The data will be assembled into the template we want, and eventually output to the user in a certain way (InnerHTML, documentwrite, etc.).
Disadvantage
1 The process of stitching strings error prone, ofte
JS and jquery Get the text, HTML, property values, value methods are not the same.JS and Jquery,text and InnerText acquisition (HTML:PID= "Test">This is in the paragraphb>Bold bodyb>Text.P> ButtonID= "Btn10">jquery display textButton> Text : This is the bold literal in the paragraph. - ButtonID= "Btn11">jquery
In the Ajax bar today, we have a higher demand for page interaction, and dynamically generated HTML is undoubtedly one of them. The dynamic generation of HTML in a variety of ways, its core is in front (JS) or back end (c#/php ... ) Assemble the data into the template we want, and finally output it to the user (InnerHTML, documentwrite, etc.) in a certain way.Disadvantages1) The process of stitching strings is error prone, often forgetting the '/' > a
Example:Copy codeThe Code is as follows:Var tbody = document. createElement ('tbody ');Tbody. innerHTML = ' Try jquery's html,Copy codeThe Code is as follows:Optional (tbody).html (' I found that jquery can be correctly displayed in IE, and there is no problem.Later, I found out that the tbody and tr innerHTML in IE are read-only and cannot be written. It is no p
Found that if I was in the DIV or other non-form tags, the original use of ordinary JS directly document.getElementById ("id"). innerHtml (or some other) is OK.But not in jquery.For example:document.getElementById ("T"). innerhtml= "DDDDDDDDDDD"; -----------A$ ("#t"). innerhtml= "Sdsds"; -----------Bdocument.getElementById ("T") obtains a DOM object, and all obje
ArticleDirectory
Disadvantages
Requirement
Solution
Implementation Principle
Summary
In the case of Ajax, we have higher requirements on page interaction, and dynamic HTML generation is undoubtedly one of them. There are multiple ways to dynamically generate HTML, with the core being in the front-end (JS) or back-end (C #/PHP ...) Assemble the data into the desired template and finally output it to the user (innerhtml, docu
I just touched jquery.Found that if I were to assign a value to a DIV or other non-form label, it would have been directly document.getElementById with normal JavaScript ("ID" ). innerHtml (or a few others) is OK, but not in jQuery !For example:document.getElementById ("t"). Innerhtml="ddddddddddd"; -----------Change the element of id= "T" to dddddddddd$ ("#t
The creation of innerHTML is a very efficient interface for nodes. jquery uses innerHTML on node operations, creating efficiencies that are at least 2-10 times faster than createelement, and can generate a bunch of nodes at a single point, but there are some compatibility issues.
I have summed up the following points, of course, compatible with the
1 DOCTYPE HTML>2 HTML>3 Head>4 MetaCharSet= "Utf-8" />5 title>Inputtitle>6 Scripttype= "Text/javascript"src= "Js/jquery-1.8.1.min.js" >Script> 7 Head>8 Body>9 Script>Ten functionchange_jq () { One A //JQ Gets the input value - varUser_val=$('#user'). Val (); - //JQ assignment to input the $('#display_val'). Val (user_val); - //modifiable ID val, etc. -
This article mainly introduces the use of innerHTML in JavaScript, examples of practical innerhtml to get the content of the corresponding elements of using skills, the need for friends can refer to the
This example describes the innerHTML usage in JavaScript. Share to everyone for your reference.
The implementation
Dom:
Copy Code code as follows:
function Displaytextboxvalue () {
var element = document.getElementById (' textbox ');
Set the attribute on the DOM Element by Hand-will update the InnerHTML
Element.setattribute (' value ', element.value);
Alert (document.getElementById ("container"). InnerHTML);
return false;
}
JQuery plugin th
Gets the HTML content of the first matching element, which cannot be used in an XML document, but can be used in an XHTML document, and in an HTML document we can use the. html () method to get the contents of any element. If the selector matches more than one element, only the HTML content of the first matching element is fetched, equivalent to the innerHTML in JavaScript, readable and writable, and HTML tags can be parsedIf callback is passed in, th
1. add jquery's js2. to add an action to the element (for demonstration, it is directly written in html): [javascript] lt; td gt; customer name: lt; inputtype amp; #39; text amp; #39; id amp; #39; name amp; #39; onblur amp; #39; burFunc () amp; #39; na
1. Add jquery js
2. Add an action for the element (for demonstration, it is directly written in html ):
[Javascript]Customer name:
3. Add a processing function:
[Javascript]Function burFunc (){
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.