Question i asked earlier along the same lines – jQuery – Selecting a child div background image and amending it. Definitely helped but im trying to simplify it down to this selector if possible.
Im looking for a way to select a child div with a class of “portlet-arrow” and get the current background-image url.
So what i need is this.
On click of the div with id “what is crm head” i need a selector that can find the child div with a class of portlet arrow and get the current background image url.
The closest i have got is this:
$( ".portlet-header" ).click(function() {
var currValue = $(this).children(".portlet-arrow").css("background-image")
});
Here is my current html
<div class="portlet" id="what-is-crm">
<div class="portlet-header header-styling" id="what-is-crm-head">
<div class="portlet-arrow red-arrow-visible"></div>
What is CRM?
</div>
<div class="portlet-content">
Mauris pretium vehicula suscipit. Donec tincidunt
volutpat risus, non pulvinar nunc feugiat ac.
<br />
<br />
<a href="#">View More</a>
</div>
</div>
I think your problem is you are missing the $ when creating a JQuery object for “this”…
Without the $ sign you will not create a JQuery object, and thus the children function will not be a valid call
Here is a working example