Use js to complete operations such as adding, deleting, modifying, and copying nodes_javascript skills

Requirements: Complete the operation of adding, deleting, modifying and copying nodes Methods and attributes used: 1. Get the parent node of a nodeparentNode attribute2. Get the parent node of a node Child node collectionchildNodes attribute3. Create a new nodecreateTextNode (node ​​text content) The method of the document object is not very compatible with some browserscreateElement (object) Methods of document objects, for example: document.createElement(“a”); 4. Add attributes and attribute values ​​to a node objectsetAttribute(attribute, attribute value); For example: aNode.setAttribute(“href” ,”http://www.baidu.com”); 5. Replace the child node under a certain nodereplaceChild(new node, atomic node); 6. Add a node to Under a nodeappendChild (node ​​to be added) 7. Clone a node cloneNode() Passing no parameters is the same as passing the true parameter, which means cloning the node includes child nodes The code is as follows: This is the second area This is the third area This is the fourth area Add: Delete: Change: Clone:

A class in JavaScript that facilitates adding, deleting, and modifying cookies

The function is assembled mainly by analyzing the document.COOKIE string. Review the operation of COOKIE in Javascript: To add COOKIE, you can use document.COOKIE=”userId=111″;The full version can be used:document.COOKIE=”userId=111;domain=.google.com;path=\;secure=secure;expire=”+date.toGMTString(); You can set the expiration time, domain name, and path of COOKIE If you need to delete it, just set the expire time to before nowNow go to the Javascript.COOKIE.js class I modified code As follows: /* COOKIE helper class easy to write,get,delete */ var myCOOKIE={ get:function(name){ if( typeof name != “undefined”) { //if name given call the get value function return myCOOKIE_get(name); }else{ //if name is not given ,i want get all the COOKIE item return myCOOKIE_getAll(); } }, add:function(name,value,options){ //write the COOKIE myCOOKIE_add(name,value,options); }, delete:function(name){ //delete the COOKIE myCOOKIE_add(name,null); } } String.prototype.Trim = function() { return this.replace(/^\s+/g,””).replace(/\s+$/g,””); } /* COOKIE write function @name:the COOKIE name not null @value:the COOKIE value null==delete the COOKIE @option:{“expires”: expire time;”path”:/;”domain”:localhost;”secure”:secure} */ function myCOOKIE_add(name,value,options) { if (typeof value ! = ‘undefined’) { // name and value given, set COOKIE optiOns= options || {}; if (value === null) { value = ”; options .expires = -1; } var expires = ”; if (options.expires && (typeof options.expires == ‘number’ || options.expires.toUTCString)) { var date; if (typeof…

JavaScript usage examples for adding, deleting, modifying and checking web page nodes

The example in this article describes the usage of Javascript for adding, deleting, modifying and checking web page nodes. Share it with everyone for your reference. The specific analysis is as follows: 1. Basic concepts This part is the so-called “HTML DOM”. The so-called HTML DOM is the Web page loading rule. It is a rule, which is the basic formula for the composition of a web page. That is, all web pages must be written according to the rules of:… and loaded according to such rules. The so-called “web page node” is also called the popular explanation of “DOM node”. For example, the content under the html node is all the content between them, and the content under the body node is all the content between them. HTML DOM is stipulated as follows: 1. The entire document is a document node; 2. Each HTML tag (meaning html tags such as , not just tags) is an element node; 3. Contained in The text in HTML elements is text nodes; 4. Each HTML attribute is an attribute node For example, a page can be drawn as the following DOM node tree: The official definition of HTML DOM is as follows:…

Some uncommon tips for adding, deleting, modifying and checking sqlserver

An Insert statement 1. Insert only default values ​​into the data: insert into [DBTrain].[dbo].[log_info] default values 2. In a field that can be null, if you want to set null, you can press [Ctrl+0]. Note that it is zero, not o. If you want to restore the value before modification, press [Esc] Two Update statements You can update the first few items or a certain percentage of data update top(3) [log_info] set info1 = ‘1001’ update top(80) percent [log_info] set info2 = ‘1002’ Three Delete statements can also use the top keyword Four Select statements 1. With Ties Execute the following sql: select top 5 * from test order by id desc The results are shown below: Execute the following sql again to see the difference: select top 5 with ties * from test order by id desc It can be seen that the current five records have not completely displayed the data of id = 2, Use with ties to display all records with id = 2 To be continued. $identity, $RowGuid,Write clause

JavaWeb——A case of adding, deleting, modifying and checking under MVC mode

Directory MVC mode Environment configuration pom.xml mybatis-config. xml Directory structure java directory: com directory: mapper directory: pojo directory: service directory: util directory: web directory&#xff1a ; resources directory: com/mapper directory: BrandMapper.xml webapp directory&# xff1a; index.html brand.jsp addBrand.jsp updateBrand.jsp MVC mode Environment configuration pom.xml 4.0.0com.myprojectbrand-demo1.0-SNAPSHOTwarmysqlmysql-connector-java8.0.21org.mybatismybatis 3.4.6javax.servletjavax.servlet-api3.1.0provided org.apache.mavenmaven-plugin-api2.0 commons-iocommons-io2.6javax.servlet.jspjsp-api2.1providedjstljstl1.2 org.apache.tomcat.maventomcat7-maven-plugin2.2 mybatis-config.xml Directory structure java directory: com directory: mapper directory: package com.mapper;import com.pojo.Brand;import java.util.List;public interface BrandMapper {List selectAll();void add(Brand brand);Brand selectById(int id);void update(Brand brand);void deletet(int id);} pojo directory: package com.pojo;/*** Brand entity class*/public class Brand {// id primary key private Integer id; // Brand name private String brandName; // Company name private String companyName; // Sorting field private Integer ordered; // Description information private String description; // Status :0:Disabled 1:Enable private Integer status;public Brand() {}public Brand(Integer id, String brandName, String companyName, String description) {this.id = id;this.brandName = brandName;this .companyName = companyName;this.description = description;} public Brand(Integer id, String brandName, String companyName, Integer ordered, String description, Integer status) {this.id = id;this .brandName = brandName;this.companyName = companyName;this.ordered = ordered;this.description = description;this.status = status;}public Integer getId() {return id;}public void setId(Integer id) {this.id = id;}public String getBrandName() {return brandName;}public void setBrandName(String brandName) {this.brandName = brandName;}public String getCompanyName() {return companyName;}public void setCompanyName(String companyName) {this.companyName = companyName;}public Integer getOrdered() {return ordered;}public…

JS sample code for adding, deleting, modifying and checking options of select control options_javascript skills-js tutorial

Javascript operation select is a common type of form. Here are several commonly used JS methods to dynamically operate select: The code is as follows: //Dynamicly create select function createSelect() { var mySelect = document.createElement (“select”); mySelect.id = “mySelect”; document.body.appendChild(mySelect); } The code is as follows: //Add option option function addOption() { //Find objects based on id, var obj=document.getElementById(‘mySelect’); //Add an optionobj.add(new Option(“text” ,”value”)); //This is only valid in IEobj.options.add(new Option(“text”,”value”)); //This is compatible with IE and firefox } The code is as follows: //Remove all options option function removeAll() { var obj=document.getElementById(‘mySelect’); obj.options.length=0; } The code is as follows: //Delete an option option function removeOne() { var obj=document.getElementById(‘mySelect’); //index, the serial number of the option to be deleted , here take the serial number of the currently selected optionvar index=obj.selectedIndex; obj.options.remove(index); } The code is as follows: //Get the text of optionvar obj=document.getElementById(‘mySelect’); var index=obj.selectedIndex; //Serial number, take the serial number of the currently selected optionvar val = obj.options[index].text; The code is as follows: //Modify option option var obj=document.getElementById(‘mySelect’); var index=obj.selectedIndex; //Serial number, take the serial number of the currently selected optionvar val = obj.options [index]=new Option(“new text”,”new value”);

Use js to complete operations such as adding, deleting, modifying, and copying nodes_javascript skills

Requirements: Complete the operation of adding, deleting, modifying and copying nodes Methods and attributes used: 1. Get the parent node of a nodeparentNode attribute2. Get the parent node of a node Child node collectionchildNodes attribute3. Create a new nodecreateTextNode (node ​​text content) The method of the document object is not very compatible with some browserscreateElement (object) Methods of document objects, for example: document.createElement(“a”); 4. Add attributes and attribute values ​​to a node objectsetAttribute(attribute, attribute value); For example: aNode.setAttribute(“href” ,”http://www.baidu.com”); 5. Replace the child node under a certain nodereplaceChild(new node, atomic node); 6. Add a node to Under a nodeappendChild (node ​​to be added) 7. Clone a node cloneNode() Passing no parameters is the same as passing the true parameter, which means cloning the node includes child nodes The code is as follows: This is the second area This is the third area This is the fourth area Add: Delete: Change: Clone:

A simple example of dynamically adding, moving, deleting, selecting all and other operations in a multi-select list box_javascript skills-js tutorial

The code is as follows: <%dim aa = split (Request.Form(“sourceList”),”,”)Response.Write “Source:” & Request.Form(“sourceList”) & ubound(a) & “Object:” & Request.Form (“objectList”) & ““%> 1 2 3 <% for i = 6 to 20 Response.Write(“” & i+200 & “” & vbcrlf) Next %> 1 4 5 <% for i = 6 to 20 Response.Write(“” & i & “” & vbcrlf) Next %>

JavaScript usage examples for adding, deleting, modifying and checking web page nodes_javascript skills

This article describes the use of Javascript for adding, deleting, modifying and checking web page nodes. Share it with everyone for your reference. The specific analysis is as follows: 1. Basic concepts This part is the so-called “HTML DOM”. The so-called HTML DOM is the Web page loading rule. It is a rule, which is the basic formula for the composition of a web page. That is, all web pages must be written according to the rules of:… and loaded according to such rules. The so-called “web page node” is also called the popular explanation of “DOM node”. For example, the content under the html node is all the content between them, and the content under the body node is all the content between them. HTML DOM is stipulated as follows: 1. The entire document is a document node; 2. Each HTML tag (meaning html tags such as , not just tags) is an element node; 3. Contained in The text in HTML elements is text nodes; 4. Each HTML attribute is an attribute node For example, a page can be drawn as the following DOM node tree: The official definition of HTML DOM is as follows: HTML DOM is…

Adding, deleting, modifying, and checking arrays of JavaScript study notes_javascript skills-js tutorial

The importance of arrays in programming languages ​​is self-evident. Arrays in Javascript are also one of the most commonly used objects. Arrays are ordered collections of values. Due to weak types, arrays in Javascript are very flexible and powerful. Unlike Arrays in strongly typed high-level languages ​​such as Java can only store elements of the same type or its subtypes. Javascript can store multiple types of elements in the same array, and the length can also be dynamically adjusted, and can be automatically adjusted as the data increases or decreases. Change the array length. Array is a common object in Javascript. It has some classic operations, such as adding, deleting, modifying and searching the array. This article mainly summarizes the relevant operation methods in this regard. Add array items First, let’s look at how to add array items to an array. Suppose there is an array: var arr = []; An array is declared above, but this array is an empty array [] with a length value of 0. Next we look at how to add array items to the array arr. The simplest way is to add array items to the array through index values: var arr = [];…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索