The use of JQuery replacewith ReplaceAll end
<%@ Page Language="Java"Import="java.util.*"pageencoding="UTF-8"%><% StringPath=Request.getcontextpath (); StringBasePath=Request.getscheme ()+ "://" +Request.getservername ()+ ":" +Request.getserverport ()+Path+ "/";%><!DOCTYPE HTML><HTML><Head><Basehref= "<%=basePath%>"><MetaCharSet= "UTF-8"><title>B Index</title><Linkrel= ' stylesheet 'type= "Text/css"href= ' B/css/bootstrap.css '></Head><Bodystyle= "margin:150px;"> <DivID= "div001">div001</Div> <DivID= "div002">div002</Div> <DivID= "div003">div003</Div> <P><span>Hello</span>, How is it?</P> <Div> <ButtonID= "btn001">Click me to replacewith new paragraph</Button> <ButtonID= "btn002">Click me to ReplaceWith div003</Button> <ButtonID= "btn003">Click me to replacewith all div with pibib</Button> <ButtonID= "btn004">Click me to paragraph ReplaceAll div001</Button> <ButtonID= "btn005">Click me to paragraph replaceall div001 use end</Button> <ButtonID= "btn006">Click me to use End</Button> </Div> <Scripttype= "Text/javascript"src= "Js/jquery-1.11.1.js"></Script> <Scripttype= "Text/javascript"src= "B/js/bootstrap.js"></Script> <Scripttype= "Text/javascript"src= "Js/index028.js"></Script></Body></HTML>
$(function() { $(' #btn001 '). Click (Btn001click); $(' #btn002 '). Click (Btn002click); $(' #btn003 '). Click (Btn003click); $(' #btn004 '). Click (Btn004click); $(' #btn005 '). Click (Btn005click); $(' #btn006 '). Click (Btn006click);});functionBtn001click () {//the writing of ' <P>ASDF ' is also possible;$ (' #div001 '). ReplaceWith (' <p>asdf '));}functionBtn002click () {$ (' #div001 '). ReplaceWith ($ (' #div003 '));}functionBtn003click () {//' <p><i><b><i><b>asdf ' such a writing, jquery self-sealing; //can also remove the wrong </ul>;$ (' div '). ReplaceWith (' <p><i><b></b></ul><i><b>asdf '));}functionBtn004click () {//in this case "<P>THISISPA" unexpectedly is invalid, must oneself seal; varRes = $ ("<p>this is Pa</p>"). ReplaceAll ($ (' #div001 '))); Console.log (RES); //no need to add back; //$ (' #div002 '). before (res);}functionBtn005click () {//with no end () will be replaced; varRes = $ ("<p>this is use end</p>"). ReplaceAll ($ (' #div002 ')) . end (); Console.log (res);}functionBtn006click () {//Obj2 got a [document] object varObj2 = $ (' p '). end (); //obj Gets the [P] object varobj = $ ("P"). FIND ("span"). end (); Console.log (obj);}
The use of JQuery replacewith ReplaceAll end