$("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 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 the original cell td content
inputIns.appendTo(tdIns).focus().select(); //Insert the input box code that needs to be inserted into the dom node
inputIns.click(function(){return false;});
inputIns.keyup(function(event){
//1. Determine whether to press Enter
//The difference in acquisition time between different browsers for the ending
var myEvent = event || window.event;
var key = myEvent.keyCode;
If(key == 13){
var inputNode = $(this);
//1. Save the content of the current text box
var inputText = inputNode.val();
//2. Clear the contents of td
inputNode.parent().html(inputText);
});
//Handle 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. Specify the next sibling element 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(): Get the previous sibling element of the specified element (the previous one).
10.prevAll(): Get all sibling elements in front of the specified element. 11. Get child elements
var aNods = $("ul > a");//Find ul under All a tags
Method 2: children()
Method 3: find()
Note:
1> The children and find methods are both used to obtain the child elements of element. Neither of them will return text node, just like most jQuery methods.
2> The children method only obtains the child elements below the element, namely: immediate children.
3> The find method obtains all subordinate elements, namely: descendants of these elements in the DOM tree
4> The parameter selector of the children method is optional (optionally) and is used to filter child elements, but the parameter selector of the find method is required.
5> The find method can actually be implemented by using jQuery(selector, context). That is, $('li.item-ii').find('li') is equivalent to $('li', 'li.item-ii').
$.validator.addMethod("isCode", function(value, element) {
var reg = /^[^u4e00-u9fa5]{1,}$/;
return this.optional(element) || (reg.test(value));
}, "Only letters, numbers and underscores can be entered");
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn