12.Set the HTML of an element
来源:百度文库 编辑:神马文学网 时间:2024/04/27 19:39:44
Set the HTML of an element
Problem
You need to modify the HTML of an element.
Solution
Use the HTML setter methods in Element
:
Element div = doc.select("div").first(); //
div.html("lorem ipsum
"); // lorem ipsum
div.prepend("First
");div.append("Last
");
// now: First
lorem ipsum
Last
Element span = doc.select("span").first(); // One
span.wrap(" ");
// now: One
Discussion
Element.html(String html)
clears any existing inner HTML in an element, and replaces it with parsed HTML.Element.prepend(String first)
andElement.append(String last)
add HTML to the start or end of an element's inner HTML, respectivelyElement.wrap(String around)
wraps HTML around the outer HTML of an element.
See also
You can also use the Element.prependElement(String tag)
and Element.appendElement(String tag)
methods to create new elements and insert them into the document flow as a child element.
12.Set the HTML of an element
Followership: An Essential Element of Leaders...
The End of an Era
"The End of an Era"
An architectural plan of the cell
1.3. Part 1: Integration of an HTML template
1.2. Integration of an HTML page template - with TemplaVoila
The World Next Week - Paraguay: end of an era...
[Governor09] Chapter 1. An Architect’s View of the Web
The Role of Tutors as an Integral Part of Online Learning Support
The Role of Tutors as an Integral Part of Online Learning Support
VOA Special English - Birth of Jazz: How an American Musical Form Came Into the World
As the Search for Survivors Scales Back, an Air of Hopelessness Descends
【丛林迷窟】(22)The Spirit of an Old Market(图)
IPA-Defining the Reference Set
An Exploration of Dynamic Documents
Establishing a community of learners: the use of Information Technology (IT) as an effective learning tool in rural primary or elementary schools
How to Create an HTML Editor Application
The power of the podcast
The color of the night
The Colors of the Rainbow
The Awesomeness of the Thundercats
The History of the Cars
Building an MVP Framework for .NET. Part 1: The Basics of MVC and MVP_宇宙支点(翘起地球,就差一根杠杆)