1 <!DOCTYPE HTML>2 <HTML>3 <Head>4 <MetaCharSet= "Utf-8" />5 <title>Input</title>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. - $("#display_val2"). attr ("value", user_val); - } + - functionChange_js () { + //JS Get A varBook_name=document.getElementById (" Book"). Value; at //JS Assign value - document.getElementById ("Book_val"). Value=Book_name; - } - - functionGet_div_val () { - varHTML=document.getElementById ("Div1"); in Console.log ('InnerHTML:'+html.innerhtml);//InnerHTML: This is a div<span> this is a span</span> - Console.log ('outerhtml:'+html.outerhtml);//outerhtml:<div id= "Div1" > It's a div<span> it's a span</span></div> to Console.log ('InnerText:'+html.innertext);//InnerText: This is a div which is a span + Console.log ('outertext:'+html.outertext);//Outertext: This is a div which is a span - } the </Script> * <H3>Input</H3> $Input content:<inputID= "User"placeholder= "Please enter ..."onchange= "CHANGE_JQ ();"type= "text">Panax NotoginsengJQ assigns a value of $ ("#id"). Val (val):<inputID= "Display_val"type= "text" > -JQ assigns a value of $ ("#id"). attr ("value", Val):<inputID= "Display_val2"type= "text" > the + <BR> A <BR> theInput:<inputID= "book"placeholder= "Please enter ..."onchange= "Change_js ();"type= "text"/> +JS Assignment:<inputID= "Book_val"type= "text" /> - <HR/> $ <H3>Div</H3> $ <inputtype= "button"onclick= "Get_div_val ()"value= "Get div content"/> - <DivID= "Div1">This is a div<span>This is a span</span></Div> - <P> theInnerHTML Sets or gets the HTML that is located within the start and end tags of the object<BR/> -outerHTML Sets or gets the HTML form of an object and its contents<BR/>WuyiInnerText set or get text that is within the start and end tags of an object<BR/> theOutertext set (including tags) or get (excluding tags) the text of an object<BR/> - </P> Wu - </Body> About </HTML>
Input via ID assignment js jquery innerhtml and outerhtml difference