Algorithm:
HTML structure is a tree structure. So when you refer $(".sonicrow")
you reach to a node with "sonicrow" as a class name. Now you need to search the children nodes which is a div...
So your code will be something like this:
- Find elements having "sonicrow" class name
- Find any children element whose type is "div"...
- Apply css
Solution:
Find a reference to the nodes having "sonicrow" as class name: var route=$(".sonicrow");
Find child nodes which is a div: var desiredChild = route.find("div");
Apply css: desiredChild.css("property","value");
...
Merge this into jquery chain:
$(".sonicrow").find("div").css('background-color', 'red');
But you want to repeat this for every element which has "sonicrow" class name, so you have to loop and your code becomes:
$(".sonicrow").each(function()
{
$(this).find("div").css('background-color', 'red');
});
P.S. I have used $(this) here because $(".sonicrow") has returned an object and you are traversing that particular object so you have to use "this" variable
to point into that element.
On the other hand, you are using Jquery so $(this) gives you an jquery object to work this, otherwise you had to use basic javascript syntax like: this.style.css.property=value
syntax :-)
I hope you have got your answer...