Use jquery edit to delete page content in two ways

Source: Internet
Author: User

The first, less edited, is edited directly on that piece of content, losing focus is done

A few days ago when editing a box, you need to modify only one State

Edit Role function Edittr ($this) {  thattd=$ ($this). parent (). prev ();  value=$.trim (thattd.html ());  Str= ' <input type= "text" id= "editing" value= "' +value+ '" > ";  thattd.html (str);  Thattd.find (' input '). focus ();} Edit completed $ (document). on (' Blur ', ' #editing ', function() {value=$ (). val (); $ (this). parent (). HTML ( value); Layer.msg (' Edit User Role complete ', {icon:1,time:1000})})        

The second, the entire line is editable implementation

Template file:lists array for the existing column, JS file processing more, Not all of them, just put an edit processing, add is to combine a string append come over, delete the direct access to the ID after the AJAX delete is Good.

1 <tbody>2             <volistname= "lists"ID= "v">3               <TR>4                   <TD>{$v. id}</TD>5                   <TD>{$v. name}</TD>6                   <TD>{$v. sort}</TD>7                   <TD><ifcondition= "$v [' default '] eq 1">YES<Else/>NO</if></TD>8                   <TDclass= "actiontd"><spanclass= "action edit">Edit</span>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<spanclass= "action del">Delete</span></TD>9               </TR>Ten             </volist> one             <TRID= "nowtr"> a               <TDID= "swid"></TD> -               <TD><inputID= "swname"type= "text"placeholder= "please fill in the software name" /></TD> -               <TD><inputID= "swsort"type= "text"class= "small"placeholder= "sort" /></TD> the               <TD> -                 <SelectID= "swdefault"> -                   <optionvalue= "1">Selected by default</option> -                   <optionvalue= "0">Default not selected</option> +                 </Select> -               </TD> +               <TDclass=""><aclass= "btn btn-success"ID= "swadd">Add to</a></TD> a             </TR> at           </tbody>
1$ (' Table '). on (' click ', ' Span.edit,span. Mjedit ',function(){2     varPre= ";3     vartdlist=$ ( this). parent (). (). find (' TD ');4     if($( this). attr (' Class ') = = ' Action Mjedit '){5Pre= ' MJ ';6     }7$ (' # ' +pre+ ' swid '). html (tdlist.eq (0). HTML ());8$ (' # ' +pre+ ' Swname '). val (tdlist.eq (1). HTML ());9$ (' # ' +pre+ ' Swsort '). val (tdlist.eq (2). HTML ());Tendefaultx= ($.trim (tdlist.eq (3). html ()) = = ' YES ')? 1:0; one$ (' # ' +pre+ ' Swdefault '). Val (defaultx); aTypename=tdlist.eq (4). HTML (); -$ ("#MJtype option:contains ('" +typename+ "')"). attr ("selected",true); -$ (' # ' +pre+ ' swadd '). html (' edit '); theLayer.msg (' please edit below '); -})//Edit End

JS file on the selector has Span.edit,span. Mjedit are two places that trigger edits, and then do a slightly different processing by attr (' class '), using the pre variable to Differentiate. It's not much of a relationship Here.

Delete page content using jquery edit, two ways

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.