By Laiacy

2020-05-22 23:28:38 8 Comments

I'm trying to select some elements from this website:

For example I try this simple selector to match all the divs elements inside the div father container with "photos__column" class:

$('div.photos__column div')

But as a result it only selects the first of all of them, why is this happening?

Thanks in advance.


@Mido elhawy 2020-05-22 23:51:35

$('div.photos__column div') return an array with all elements with this pattern "div.photos__column div" but whene you call a function like text() , the function text use only the firest rsult of array

if you want to do an operation on all selected element , can you use :

$('div.photos__column div').each(function( index ) {
  console.log( index + ": " + $( this ).attr("src") );

or if you want to select element by index , you can call element by hir index for example : $('div.photos__column div')[2]

can you use this query to get all img source from the home page :

var allimegs = document.querySelectorAll(".photo-item__img");
var newsrc = [] ;for(var i = 0;i<allimegs.length;i++){
    newsrc[i] = allimegs[i].getAttribute("src"); 

@Sebastian B. 2020-05-22 23:33:10

$ could be anything.

Does this site have jQuery at all? You can check it in the browser console via


Querying with native DOM API

document.querySelectorAll('div.photos__column div')


@Jacob 2020-05-22 23:36:09

To elaborate on this, if you're just using the Chrome console, $ is an alias for document.querySelector, and $$ is document.querySelectorAll. The former only selects one element. Indeed, that site doesn't seem to have jQuery.

Related Questions

Sponsored Content

7 Answered Questions

[SOLVED] jQuery: Get selected element tag name

17 Answered Questions

[SOLVED] CSS selector for first element with class

  • 2010-04-26 22:51:13
  • Rajat
  • 1010874 View
  • 944 Score
  • 17 Answer
  • Tags:   css css-selectors

22 Answered Questions

13 Answered Questions

[SOLVED] How can I select an element with multiple classes in jQuery?

3 Answered Questions

[SOLVED] Why do browsers match CSS selectors from right to left?

13 Answered Questions

[SOLVED] How can I select an element by name with jQuery?

4 Answered Questions

[SOLVED] jQuery select all except first

15 Answered Questions

[SOLVED] Using jQuery to test if an input has focus

11 Answered Questions

[SOLVED] JQuery .each() backwards

2 Answered Questions

[SOLVED] Not class selector in jQuery

Sponsored Content