What is the jQuery selector for selecting anchor elements with a particular class in a particular div

三世轮回 提交于 2019-12-05 14:30:26

You can do this $('#foo').find('.status')

The selector would be:

$("#foo a.status");

Try this and read this:

$("#foo a.status")

Good luck!

This works.

$("#foo").find("a.status")

Try this:

$('div#foo a.status')

The docs are here

try with

$('div#foo > a.status')

it selects the anchors which are DIRECT children of div #foo

jQuery('#foo')     //select elm with id foo
.find('a.status')  //find anchor with class

There is no such thing as a "jQuery selector", what you mean is :

either CSS selector :

In that case the answer is div#foo a.status or also div#foo > a.status (depending if there are intermediate containers)

or jQuery functions :

In that case there are several ways to do it :

  • $('div#foo a.status')
  • $('div#foo > a.status')
  • $('div#foo').find('a.status')
  • $('div#foo').children('a.status')
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!