<div class="booking"> <div class="booking-date"> <span>19 мая</span><br> понедельник </div> <ul> <li><a href="#">11:00</a></li> <li><a href="#">12:00</a></li> <li><a href="#">13:00</a></li> </ul> </div> <div class="booking"> <div class="booking-date"> <span>23 мая</span><br> понедельник </div> <ul> <li><a href="#">11:00</a></li> <li><a href="#">12:00</a></li> <li><a href="#">13:00</a></li> </ul> </div> 

There is such a piece of layout, gentlemen. Suppose that I can pass a specific span value to a javascript as well as a specific text inside the a tag , that is, the basic parameters are known.

Now the question is: how to address this particular a corresponding to a specific span whose values ​​are known in advance? Otherwise, how to refer to the link with the text 13.00 which corresponds to the span with the text on May 23?

    1 answer 1

    http://jsfiddle.net/7T42U/

    But I would advise you to use data- * attributes and add something like this:

     <div class="booking"> <div class="booking-date"> <span>19 мая</span><br> понедельник </div> <ul data-date="19 мая"> <li><a href="#">11:00</a></li> <li><a href="#">12:00</a></li> <li><a href="#">13:00</a></li> </ul> 

    Then it would be possible to simplify the selector - http://jsfiddle.net/7T42U/1/