0
I have a tag <legend>texto</legend>
that I don’t 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 amend the text of the first or the X <legend>
I tried with jquery to get all the children items from div
Something like
$("#div1teste").childreen
Now I’m trying to create a class="test" on <legend>
and try to get him back:
document.getElementsByClassName("teste")[0];
But both to no avail.
NOTE: I just can’t insert id in this <legend>
because this whole page is created dynamically and it would be a little complex to put Id on it.
Example in Jsfiddler https://jsfiddle.net/dorathoto/8yks4e5j/
You can browse all the elements and exchange the texts as you wish, see if this helps: https://jsfiddle.net/8yks4e5j/2/
– abfurlan
abfurlan, show, best way, already traverse by everyone, great..
– Dorathoto
@abfurlan and if I wanted to split into 2 types, see https://jsfiddle.net/dorathoto/8yks4e5j/3/ for one to change only one Legend type and the other Legend would be possible?
– Dorathoto
Scroll through the child elements of each div like this: https://jsfiddle.net/8yks4e5j/4/
– abfurlan
I posted it in response, since it helped you can help other people :)
– abfurlan