0

In a javascript function , the evt.target returns the following html :-

<select id="reportChannelsSelect" class="form-control" multiple="true" data-placeholder="Choose a Channel..." style="display: none;">                               
                        <option value="maintenance" id="channel-5c5812708065f536068819">maintenance</option>
                        <option value="operations" id="channel-5c5812a220fcd273648996">operations</option>                       
                       <option value="Private Testing Channel" id="channel-5631e7c4a317d864607733">Private Testing Channel</option>
                       <option value="TipsTest" id="channel-5cee1aea6ddf1527975644">TipsTest</option>
</select>

Also I have a filter text value - operations. Using this text,how can I fetch the value of id , which is "channel-5c5812a220fcd273648996" in this case.

Webdev
  • 617
  • 6
  • 24
  • can you share that javascript function also? need to know it is an element or something elese – Codesigner May 27 '20 at 08:31
  • 1
    *" In a javascript function , the evt.target returns the following html"* No, it returns an *element*, which might contain the DOM structure you can represent with that HTML. To find an element within it by attribute using jQuery, use `$(evt.target).find("[value='" + filter + "']")` (assuming the text in `filter` doesn't have any `'` in it). – T.J. Crowder May 27 '20 at 08:31

0 Answers0