1. Get TD's Row and column labels
Copy Code code as follows:
$ (this). Prop (' CellIndex ')
2. Determine if it is a carriage return press
Copy Code code as follows:
var myevent = Event | | window.event;
var key = Myevent.keycode;
if (key = = 13) {
Press ENTER at this time
}
3. Select all and reverse the election
Copy Code code as follows:
$ ("#selectall"). Click (function () {
if ($ ("Input[name= ' id[] ')"). Is (": Checked")) {
$ ("Input[name= ' id[]"). Prop ("checked", false);
}else{
$ ("Input[name= ' id[]"). Prop ("checked", true);
}
});
4. Double-click Modify Enter to save the TD item in the table double click event
Copy Code code as follows:
$ ("TD"). DblClick (function () {
var tdins = $ (this);
var Tdpar = $ (this). Parents ("tr");
Tdpar.css ("Background-color", "yellow");
if (Tdins.children ("input"). length>0) {return false;}
var inputins = $ ("<input type= ' text '/>"); Input box code that needs to be inserted
var text = $ (this). html ();
Inputins.width (Tdins.width ()); Set input to be consistent with TD width
Inputins.val (tdins.html ()); Copy the original cell TD content to the inserted text box input
Tdins.html (""); Delete Original cell TD content
Inputins.appendto (tdins). focus (). Select (); Insert the input box code you want to insert into the DOM node
Inputins.click (function () {return false;});
Inputins.keyup (function (event) {
1. Determine whether to enter the press
The difference between different browser acquisition times in the end
var myevent = Event | | window.event;
var key = Myevent.keycode;
if (key = = 13) {
var Inputnode = $ (this);
1. Save the contents of the current text box
var inputtext = Inputnode.val ();
2. Clear the contents of TD
Inputnode.parent (). HTML (inputtext);
}
});
Handling the Enter and ESC events
Inputins.blur (function () {
var Inputtext = $ (this). Val ();
Tdins.html (Inputtext);
Tdpar.css ("Background-color", "white");
tdins.html (text);
});
});
5. Parent element $ (this). parent ();
6. Specifies the next sibling of the element $ (this). Next ();
7. All sibling elements of the specified element $ (this). Nextall ();
8. Specify the element and all sibling elements $ (this). Andself ();
9.prev (): Gets the previous sibling element of the specified element, which is the previous one.
10.prevAll (): Gets all the sibling elements at the front of the specified element.
11. Get Child elements
Way a:>
Copy Code code as follows:
var anods = $ ("ul > A");/Find all the A tags under UL
Mode two: Children ()
Mode three: Find ()
Attention:
1> children and Find methods are used to obtain the element's elements, neither of which returns text node, as most jquery methods do.
The 2> children method obtains only the element one subordinate child element, namely: immediate children.
The 3> Find method obtains all the subordinate elements, namely: descendants of these elements in the DOM tree
The parameter selector of the 4> children method is optional (optionally) to filter the child elements, but the parameter selector method of the Find method is required.
The 5> Find method can actually be implemented by using JQuery (selector, context). That is $ (' li.item-ii '). Find (' Li ') equals $ (' li ', ' Li.item-ii ').
12. Get the first element:
Copy Code code as follows:
$ ("#getfirst"). Find ("ul Li:first-child")
$ ("#getfirst"). Find ("ul Li"). Get (0)
$ ("#getfirst"). Find ("ul Li").
13.datepicker Common Date selection plugin DatePicker
Copy Code code as follows:
$ ("#waybill_eta1"). DatePicker ({dateformat: ' Yy-mm-dd '});
14. Date and time the simultaneous selection of Plug-ins DateTimePicker
Copy Code code as follows:
$ (' #declare_time '). DateTimePicker ({
DateFormat: ' Yy-mm-dd ',
TimeFormat: ' hh:mm ',
});
15.validate Regular Add validation method
Copy Code code as follows:
$.validator.addmethod ("Iscode", function (value, Element) {
var reg =/^[^\u4e00-\u9fa5]{1,}$/;
return this.optional (Element) | | (Reg.test (value));
"Only alphanumeric and underline" can be entered;