1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 <MetaCharSet= "Utf-8">5 <Scriptsrc= "Https://cdn.bootcss.com/jquery/1.10.2/jquery.min.js"></Script>6 <Scripttype= "Text/javascript">7 $(function(){8 $("#btn1"). Click (function(){9 $("#test1"). Text (function(i,oldval) {Ten return "Old text:"+Oldval+"new text: You and I he study it (index:"+I+")"; One }) A }) - $("#btn2"). Click (function(){ - $("#test2"). HTML (function(i,oldhtml) { the return "Old HTML:"+oldhtml+"New HTML: You and I he <b> study bar </b> (index:"+I+")"; - }) - }) - }) + </Script> - </Head> + A <Body> at <PID= "Test1">This is in the paragraph<b>Bold body</b>Text.</P> - <PID= "Test2">This is another one that has<b>Bold</b>Paragraph of the word.</P> - <ButtonID= "BTN1">Show new/Old text</Button> - <ButtonID= "BTN2">Show new/Old HTML</Button> - </Body> - </HTML>
"Learn to light it" jQuery text ()/html () callback function instance