Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Child selector deprecated [duplicate]

Possible Duplicate:
What is the new proper way to use a child selector with a context node in jQuery?

From the jQuery docs:

Note: The $("> elem", context) selector will be deprecated in a future release. Its usage is thus discouraged in lieu of using alternative selectors.

http://api.jquery.com/child-selector/

What would be an alternative selector for this?

like image 703
PeeHaa Avatar asked Oct 20 '11 09:10

PeeHaa


People also ask

How to select a specific child element in CSS?

The :nth-child(n) selector matches every element that is the nth child of its parent. n can be a number, a keyword (odd or even), or a formula (like an + b). Tip: Look at the :nth-of-type() selector to select the element that is the nth child, of the same type (tag name), of its parent.

How do I select immediate child in CSS?

The CSS child combinator ( > ) can be used to select all elements that are the immediate children of a specified element. A combinator combines and explains the relationship between two or more selectors.

Which tag is used for child selector?

With <li> tag.

What is a child selector?

A child selector matches when an element is the child of some element. A child selector is made up of two or more selectors separated by ">". Example(s): The following rule sets the style of all P elements that are children of BODY: body > P { line-height: 1.3 }


2 Answers

$(context).children('elem')

also $("> elem", context) is deprecated, but $(context+" >elem") and $("parent>child") are not

like image 113
Yamiko Avatar answered Oct 18 '22 08:10

Yamiko


$('parent').children('childrenelements')

Is my guess :)

But as the other poster said, its only searching directly for childs in a context.

like image 1
Marco Johannesen Avatar answered Oct 18 '22 09:10

Marco Johannesen