Forums

The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums JavaScript Jquery selectors help!

  • This topic is empty.
Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #154232
    Manuel87
    Participant
    <select id="variant"></select>
    <div>123</div>
    <div id="options">
     <img>
    </div>
    

    I need to use jquery to select the <select> tag with the id of “variant” when a user clicks on the<img /> tag. somebody please help me.

    #154233
    __
    Participant

    I need to use jquery to select the tag with the id of “variant” when a user clicks on the tag. somebody please help me.

    Which <img> tag? any img tag?

    #154292
    Manuel87
    Participant

    the <img> tag that is inside <div id="options">

    #154338
    __
    Participant

    the <img> tag that is inside <div id="options">

    well, to explain why I am asking:

    $('img')
    

    will select that <img> tag. However, it will also select any other image that might be on the page.

    $('#options img')
    

    will select it also, but would also select any other image (if any) that might be inside that div. So, you just need to figure out exactly how you’re going to identify the image you want. I would think that this selector (the second one I mentioned) is probably what you want, but I can’t answer that for sure.

    However, as @crocodillon says, if all you need to do is move the focus to the <select> input, use a label.

    #154357
    Manuel87
    Participant

    yes thanks what @crocodillon suggested worked for me thanks.

Viewing 5 posts - 1 through 5 (of 5 total)
  • The forum ‘JavaScript’ is closed to new topics and replies.