1
I have the following HTML:
<div class="block_content_inner">
<div class="details_block">
<b>Title:</b>
"Titulo do Filme"
<b>Genre:</b>
<a href="#">Action</a>
<a href="#">Adventure</a>
<a href="#">Fantasy</a>
<div class="director_row">
<b>Director</b>
<a href="#">Diretor 1</a>
<a href="#">Diretor 2</a>
</div>
<div class="director_row">
<b>Studio</b>
<a href="#">Studio 1</a>
<a href="#">Studio 2</a>
</div>
<div class="director_row">
<b>Serie</b>
<a href="#">Nome da Trilogia</a>
</div>
</div>
I need to reference the first 3 tags <a>
who are just after the tag <b>Genre</b>
, but can happen to have 1 tag a
or several, it would need to be in a dynamic way.
I almost got it, but in one attempt it brings only the value of the first tag <a>
or brings values of all tags <a>
that are in this div, including those within the <div class="director_row">
I would need the value of tags <a>
after the tag <b>Genre</b>
and before the div <div class="director_row">
.
I can’t manipulate HTML, I just need to reference the way it already exists.
"which are just after the <b>Genre</b tag>" the selector
".details_block > a"
would work for this case, for the tags exactly after the tag "b"?– Ricardo Pontual
@Ricardopunctual yes would work, the "problem" is that it takes all of the <a> direct children, no matter the position, it means that if you have a <a> there at the end after the last Row it will also be selected. But as his code does not have this other element, I thought it could be of some use, since it selects only the elements described
– hugocsl
Good answer, but it seems to me that he wants to select the elements to do some manipulation via jQuery, and not to change styles. Soon via CSS seems to me not to be useful in this case. : / Let’s see what he will say. If it’s just to change style, will choose your answer; :D
– Sam
Ah tah rs... had not seen the part with jQuery catching the direct children. It is a cool way tb, as long as it does not invent to later add other links within the div rs.
– Sam
@Sam I had put with jQuery later, then he can manipulate as he wants. This question that you raise sometimes frustrates me a little. Because we give an answer that works for what was posted in the question.... Then after we answer, come the "replicates" and if that, and if that... ai complica rss. In case if he tv any other direct <a> son the selector tb will pick him up, but as in the question does not have, I thought that would be a fitting answer :), but if he says he has another direct <a> son that he does not want to catch my rule will fall, or I will need one . not() maybe
– hugocsl
I understand and I think it is exaggerated to even foresee possibilities that could disable the answer, but there is a lot here of taking -1 in the answer because the approach does not foresee possibilities. I don’t particularly give -1 in answers like that, unless it’s something loud. But it’s cool. Often when the answer does not foresee possibilities, the AP appears the other day asking for rss corrections... tmj
– Sam
@Sam we have some users who are experts on this :/
– hugocsl
@hugocsl All the answers were good, some did not reach my goal but taught me something new. I appreciate your taking the time to assist me. I chose the other answer as correct just because it is a little more complete, but both achieve my goal. Thank you also for teaching me something new.
– D. Watson
@D.Watson quiet young don’t worry about it, I’m happy to help! []s
– hugocsl