Home Web Front-end JS Tutorial Detailed analysis of the difference between children and find in Jquery_jquery

Detailed analysis of the difference between children and find in Jquery_jquery

May 16, 2016 pm 05:11 PM
children find jquery

First look at a piece of HTML code, as follows:

Copy the code The code is as follows:

&lt ;table id="tb">
                                                                              🎜>                                                                              td>
            </tr>
                                                              td>4</td>
                                                            /td>
                                                                                                                                                                                                   </tr>
</table>


If I want to get the value of the second td in the second tr:


Children:


Copy code


Find :


Copy code
As a result, the value obtained through children is: null, and through The value obtained by find is: 4. Why is this?

After checking the information, what is obtained through children is the subordinate elements of the element, and what is obtained through find is all the subordinate elements of the element.
Now back to the above, we can conclude that $("#tb>tbody").children() obtains two tr elements (excluding their child elements td),
The selector in children is to filter the two obtained tr elements according to the conditions, so the above writing method cannot get the value.

If we must use children, we can write it like this:

Copy the code

Statement of this Website
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

Hot Article Tags

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Detailed explanation of jQuery reference methods: Quick start guide Detailed explanation of jQuery reference methods: Quick start guide Feb 27, 2024 pm 06:45 PM

Detailed explanation of jQuery reference methods: Quick start guide

How to use PUT request method in jQuery? How to use PUT request method in jQuery? Feb 28, 2024 pm 03:12 PM

How to use PUT request method in jQuery?

How to remove the height attribute of an element with jQuery? How to remove the height attribute of an element with jQuery? Feb 28, 2024 am 08:39 AM

How to remove the height attribute of an element with jQuery?

jQuery Tips: Quickly modify the text of all a tags on the page jQuery Tips: Quickly modify the text of all a tags on the page Feb 28, 2024 pm 09:06 PM

jQuery Tips: Quickly modify the text of all a tags on the page

OPPO Find X7 is a masterpiece! Capture your every moment with images OPPO Find X7 is a masterpiece! Capture your every moment with images Aug 07, 2024 pm 07:19 PM

OPPO Find X7 is a masterpiece! Capture your every moment with images

Use jQuery to modify the text content of all a tags Use jQuery to modify the text content of all a tags Feb 28, 2024 pm 05:42 PM

Use jQuery to modify the text content of all a tags

OPPO Find X8 Ultra core configuration exposed! Snapdragon 8 Gen4+ Extra Large Battery OPPO Find X8 Ultra core configuration exposed! Snapdragon 8 Gen4+ Extra Large Battery Aug 22, 2024 pm 06:54 PM

OPPO Find X8 Ultra core configuration exposed! Snapdragon 8 Gen4+ Extra Large Battery

Understand the role and application scenarios of eq in jQuery Understand the role and application scenarios of eq in jQuery Feb 28, 2024 pm 01:15 PM

Understand the role and application scenarios of eq in jQuery

See all articles