I am currently working with the liferay framework and I am facing a challenge where I need to apply inline JavaScript to target a very specific div on my webpage. The catch is that this div is nested within multiple dynamically added divs with varying classes and IDs. To make matters more complicated, these divs can either be siblings or nested within each other randomly.
Here's an example of what I'm dealing with:
<div class="known-class">
<div class="unknown dynamicallygenerated"></div>
<div class="unknown dynamicallygenerated">
<div class="unknown dynamicallygenerated">
<div class="unknown dynamicallygenerated"></div>
<div class="unknown dynamicallygenerated">
<div class="DIV-I-WANT-TO-TARGET">this is the div i need to Target with my css/javascript</div>
</div>
</div>
</div>
Simply targeting it using the class name won't work due to similar classes elsewhere in the page. A possible solution would be something like:
jQuery('.known-class .DIV-I-WANT-TO-TARGET')
However, this approach fails because my desired div is not directly under the ".known-class" div, but nested inside others.
I have been exploring if there might be a jQuery method to assist me. Perhaps:
Select any div with .DIV-I-WANT-TO-TARGET
class that is nested within another div containing .known-class
Is there a way to achieve this? Your help is greatly appreciated!