I have a <legend>texto</legend>
tag that does not have Id and can have several on one page, I would like to change based on the ID of the previous div
ex:
<div id="div1teste">
<fieldset>
<legend>texto</legend>
</div>
<div id="div2teste">
<fieldset>
<legend>texto</legend>
</fieldset>
</div> </fieldset>
I would like to change the text of the first or the X% with% I tried with jquery to grab all the child items from the div Something like
$("#div1teste").childreen
Now I'm trying to create a class="test" in <legend>
and try to recover it:
document.getElementsByClassName("teste")[0];
But both to no avail.
NOTE: I can not just insert id in this <legend>
because that whole page is created dynamically and would be a bit complex to put Id in it.
Example in Jsfiddler link