Many times we will see the text on the webpage, which can be edited as long as we click it. Next I will introduce a Summary of the javascript Mouse clicking text to text box code, for more information, see.
The Code is as follows: |
Copy code |
<Style type = "text/css"> Body {font-size: 13px ;} . Sortname {height: 30px ;} </Style> <Script src = "/jquery-1.7.1.js" type = "text/javascript"> </script> <Script type = "text/javascript"> $ (Document). ready (function (){ $ (". Sortname"). click (function (){ If ($ (this). find (". sort_input"). attr ("type") = "text") {return false ;} Var name = pai.trim(((this).html ()); Var m = $. trim ($ (this). text ()); Optional (this).html ("<input type = text value =" "+ name +" "class =" sort_input "> "); $ (This). find (". sort_input"). focus (); $ (This). find (". sort_input"). bind ("blur", function (){ Var n = $. trim ($ (this). val ()); If (n! = M & n! = ""){ // Window. location = "sort. php? Val = "+ encodeURIComponent (n ); // Send information Certificate (this).parent().html (n ); } Else { Certificate (this).parent().html (name ); } }); }); }); </Script> </Head> <Body> <Div class = "sortname"> Baidu </div> <Div class = "sortname"> Google </div> |