We help IT Professionals succeed at work.
Get Started
Troubleshooting Question

Is It Possible to Capture Value of Pseudo Select List Box, onClick?

36 Views
Last Modified: 2021-01-19
I'm dealing with a web app that has functionality that acts like a select list box but really isn't. Is there a way to get the actual text of this code below onClick of one of the list items? I'd want Value A, Value B or value C returned when clicked on. Need to use event listener due to not being able to modify mark-up. Must work with IE 11 and JavaScript Only.
<div class="select2-drop select2-display-none select2-drop-active" style="display: block; left: 280px; width: 390px; top: 305.4px; bottom: auto;" id="select2-drop">
    <div class="select2-search select2-search-hidden select2-offscreen">
        <label for="s2id_autogen1_search" class="select2-offscreen"></label>
        <input type="text" class="select2-input" role="combobox" aria-expanded="true" aria-autocomplete="list" aria-owns="select2-results-1" id="s2id_autogen1_search">
    </div>
    <ul class="select2-results" role="listbox" id="select2-results-1">
        <li class="select2-results-dept-0 select2-result select2-result-selectable" role="presentation">
            <div class="select2-result-label" id="select2-result-label-135" role="option"><span class="select2-match"></span>value A</div>
        </li>
        <li class="select2-results-dept-0 select2-result select2-result-selectable" role="presentation">
            <div class="select2-result-label" id="select2-result-label-136" role="option"><span class="select2-match"></span>value B</div>
        </li>
        <li class="select2-results-dept-0 select2-result select2-result-selectable" role="presentation">
            <div class="select2-result-label" id="select2-result-label-137" role="option"><span class="select2-match"></span>value C</div>
        </li>
    </ul>
</div>
Thanks!
Comment
Watch Question
Sr. System Analyst
CERTIFIED EXPERT
Commented:
This problem has been solved!
Unlock 1 Answer and 28 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE