Some basic operations of Jquery form value assignment_jquery
Selector with qualified child nodes: $("mix1[mix2]"): Returns the mix1 node containing mix2. For example: $("div[a]"): A div containing the a tag.
This is the same as $(" div a") are not the same. The latter represents the a tag in the div and returns the a tag object. The former returns the div tag object
Colon-qualified node selector: $("mix:condition"):mix tag, and meet the qualifying conditions.
E:root: The type is E, and it is the root element of the document
E:nth-child(n): It is the nth child element of type E of its parent element , the base starts from 1
E:first-child: is the first child element of type E of its parent element
E:last-child: is the last child element of type E of its parent element
E:only-child: and is the only child element of type E of its parent element
E:empty: an element of type E that has no child elements (including text nodes)
E:enabled
E:disabled: User interface elements of type E, allowed or prohibited
E:checked: User interface elements of type E, in selected state (such as radio buttons or check boxes)
E:visible: Select all visible elements (the display value is block or visible, the visibility value is visible elements, excluding the hide field)
E:hidden: Select all hidden elements (non-Hide field, and the display value is block or visible) , elements whose visibility value is visible)
E:not(s): type is E, does not match selector s
E:eq(n),E:gt(n),E:lt(n) :Element qualification
E:first: Equivalent to E:eq(0)
E:last: The last matching element
E:even: Take the even-numbered element from the matched element set
E:odd: Take odd-numbered elements from the matched element set
E:parent: Select all elements that contain child elements (including text nodes)
E:contains('test'): Select all elements containing Elements that specify text
Form selector:
E:input: Select form elements (input, select, textarea, button)
E:text: Select all text areas (type="text")
E:password: select all password fields (type="password")
E:radio: select all radio buttons (type="radio")
E:checkbox: select all checkboxes (type= "checkbox")
E:submit: Select all submit buttons (type="submit")
E:image: Select all image fields (type="image")
E:reset: Select all clear Domain (type="reset")
E:button: Select all buttons (type="button")
Of course including E:hidden
8.xPath path query:
First introduce the syntax of xPath:
/: Select the root node
//: Select all nodes that meet the conditions in the document, no matter where the node is located
.: Select the current node
.. :Select the parent node of a single previous node
@:Select attributes, this has been mentioned before (attribute selector)
nodename:Select all nodes under the node
Application in jQuery:
Root Nodes are rarely used, commonly used examples are as follows:
$("div/p") is equivalent to $("div>p")
$("div//p") is equivalent to $("div p")
$("//div/../p"): The p tag under the parent node of all div nodes
also has relative path writing and supported Axis selectors. I don’t know how to apply it yet, so I won’t introduce it... There are already a lot of other uses of
$:
$ (html node): dynamically created based on the original HTML tag string provided DOM elements wrapped by jQuery objects. For example:
$("Hello").appendTo("#body");//Add Hello to the body element
$(document): Web page document object
$(document.body): Web page body object, which is the same as $("body")
$(function): This function is executed after the DOM is loaded. So $(document).ready() can be written Do $()
$(selector part, selector source): This example illustrates
$("input:radio",document.forms[0]): In the first form of the document, search All radio buttons
$("div",xml.responseXML): Query all div elements in the specified XML document
The selector source can be: DOM element, document or jQuery object as context
Also There are two: $.extend(prop) and $.noConflict() are compatible with plug-ins and other libraries. We will write
drop-down boxes, radio button boxes, and multi-select boxes in the future
1, drop-down box:
var cc1 = $(".formc select[@name='country'] option[@selected]").text(); //Get the text of the selected item in the drop-down menu (Note that there are spaces in the middle)
var cc2 = $('.formc select[@name="country"]').val(); //Get the value of the selected item in the drop-down menu
var cc3 = $ ('.formc select[@name="country"]').attr("id"); //Get the ID attribute value of the selected item in the drop-down menu
$("#select").empty(); //Clear the drop-down box//$("#select").html('');
$("1111").appendTo("#select")//Add the option of the drop-down box
A little explanation Here's a look:
1.select[@name='country'] option[@selected] means the option element with the selected attribute in the select element that has the name attribute,
and the attribute value is 'country';
It can be seen that anything starting with @ means that it is followed by attributes.
2, radio button:
$("input[@type=radio][@checked]").val(); //Get the value of the selected item of the radio button (note the middle No spaces)
$("input[@type=radio][@value=2]").attr("checked",'checked'); //Set the radio button value=2 to the selected state. (Note that there is no space in the middle)
3, check box:
$("input[@type=checkbox][@checked]").val(); //Get the check box selected The value of the first item
$("input[@type=checkbox][@checked]").each(function(){ //Since multiple check boxes are generally selected, the output can be looped
alert($(this).val());
});
$("#chk1").attr("checked",'');//uncheck
$("#chk2").attr("checked",true);//Tick
if($("#chk1").attr('checked')==undefined){} // Determine whether it has been checked

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Detailed explanation of jQuery reference method: Quick start guide jQuery is a popular JavaScript library that is widely used in website development. It simplifies JavaScript programming and provides developers with rich functions and features. This article will introduce jQuery's reference method in detail and provide specific code examples to help readers get started quickly. Introducing jQuery First, we need to introduce the jQuery library into the HTML file. It can be introduced through a CDN link or downloaded

How to use PUT request method in jQuery? In jQuery, the method of sending a PUT request is similar to sending other types of requests, but you need to pay attention to some details and parameter settings. PUT requests are typically used to update resources, such as updating data in a database or updating files on the server. The following is a specific code example using the PUT request method in jQuery. First, make sure you include the jQuery library file, then you can send a PUT request via: $.ajax({u

How to remove the height attribute of an element with jQuery? In front-end development, we often encounter the need to manipulate the height attributes of elements. Sometimes, we may need to dynamically change the height of an element, and sometimes we need to remove the height attribute of an element. This article will introduce how to use jQuery to remove the height attribute of an element and provide specific code examples. Before using jQuery to operate the height attribute, we first need to understand the height attribute in CSS. The height attribute is used to set the height of an element

Title: jQuery Tips: Quickly modify the text of all a tags on the page In web development, we often need to modify and operate elements on the page. When using jQuery, sometimes you need to modify the text content of all a tags in the page at once, which can save time and energy. The following will introduce how to use jQuery to quickly modify the text of all a tags on the page, and give specific code examples. First, we need to introduce the jQuery library file and ensure that the following code is introduced into the page: <

This article will show you how to enable or disable automatic copying of selections to the clipboard in Windows Terminal. Windows Terminal is a multi-tab terminal emulator developed by Microsoft specifically for Windows 11/10, replacing the traditional command prompt. It supports running applications such as Command Prompt, PowerShell, WSL, Azure, etc. Often when working in the terminal, users need to copy commands and output, however the terminal does not support copying selection operations by default. Keep reading this article to learn how to fix this issue. How to enable or disable automatic copying of selections to cache in Terminal? Here's how you can enable or disable automatic copying of selections to the Terminal clipboard: Open the Terminal application and click above

Title: Use jQuery to modify the text content of all a tags. jQuery is a popular JavaScript library that is widely used to handle DOM operations. In web development, we often encounter the need to modify the text content of the link tag (a tag) on the page. This article will explain how to use jQuery to achieve this goal, and provide specific code examples. First, we need to introduce the jQuery library into the page. Add the following code in the HTML file:

Forms are an integral part of writing a website or application. Laravel, as a popular PHP framework, provides rich and powerful form classes, making form processing easier and more efficient. This article will introduce some tips on using Laravel form classes to help you improve development efficiency. The following explains in detail through specific code examples. Creating a form To create a form in Laravel, you first need to write the corresponding HTML form in the view. When working with forms, you can use Laravel

jQuery is a popular JavaScript library that is widely used to handle DOM manipulation and event handling in web pages. In jQuery, the eq() method is used to select elements at a specified index position. The specific usage and application scenarios are as follows. In jQuery, the eq() method selects the element at a specified index position. Index positions start counting from 0, i.e. the index of the first element is 0, the index of the second element is 1, and so on. The syntax of the eq() method is as follows: $("s
