I'm trying to write javascript that will will show/hide a paragraph when I click on an arrow. The catch is, I am generating a list of titles and next to each title is an arrow. This is generated through a loop on the server. When its passed the code has no ID. To solve that, I ran the following javascript to create ID's:
var countPosts = document.getElementsByClassName("jobs-article-holder-content-whole-teaser").length;
var myNewID = "article-holder-dropdown-"
for (var i = 0; i < countPosts; i++) {
myNewID = "article-holder-dropdown-" + (i + 1);
document.getElementsByClassName("jobs-article-holder-content-whole-teaser")[i].setAttribute("id", myNewID);
}
html is
loop
<div class="jobs-article-holder-content-page">
<div class="jobs-article-holder-content-whole">
<div class="jobs-article-holder-content-whole-box">
<h3>$MenuTitle.RAW</h3>
<div class="job-article-holder-click-for-more-link">
▲
</div>
</div>
<div class="jobs-article-holder-content-whole-teaser show">
<p class="jobs-article-holder-content-whole-teaser-content">$Teaser</p>
</div>
</div>
</div>
end loop
To give you a visual:
Now I'm trying to figure out how can I click on an arrow and have the content hide/show if I don't know the ID's. Any Idea's?
EDIT:
One thing I can't seem to get around is that the arrow is inside one div, where the paragraph is inside another, how do I change the arrow and hide the div, passing (this) can affect only the arrow, how can I go from there to affect the paragraph?