Get Clicked Option In Multiple Dropdown January 26, 2024 Post a Comment I have a multi select dropdown eg: Opt #1Solution 1: You can get it in the click handler for each option element:$("#myList option").click(function() { var clickedOption = $(this); }); CopyUpdateEDIT: As I manipulate the list inside a change event, I can't do it in a click event.In that case you need to delegate the event using on. Try this:$("#myList").on("click", "option", function() { var clickedOption = $(this); }); CopyOne thing to note, however, is that option elements will not raise click events at all in IE, so neither of the above will not work in that browser.Solution 2: As you know, If the user clicked on opt #4 without Cntrl key pressed, then you will only get Opt#4 as the selected option.If the user clicked on opt #4 with Cntrl key pressed, then all three options will be selected. So all three options will be returned. If you want only Opt#4, then you would need to add a click event handler.Solution 3: Would something like the following help you?$('#myList').delegate('option', 'click', function (opt) { alert('Option ' + opt.value + ' was clicked'); }); CopySolution 4: The real answer:select.onclick = function(e) { console.log(e.target.value); }; Copy Share Post a Comment for "Get Clicked Option In Multiple Dropdown" Top Question How To Style A Programatically Add Element In Angular Could I please ask for help with the following (pictures ar… Mobx Observable Array Not Updated I am declaring a observable array in the following way in r… How To Specify Color Space For Canvas In JavaScript? What is the default color space used in JS canvas? How can … How Can I Force Download With Html And/or Javascript? So I have a this code: My Song How can I make it so t… Javascript Math Different To What I Thought It Should Be Just wondering if someone knows what is wrong with my javas… Rxjs - Consume API Output And Re-query When Cache Is Empty I'm trying to implement a version of this intro to RxJS… How Can I Remove Data Which Is Stored In Local Storage? If I console.log(localStorage.getItem('cartCache'))… How Can I Detect CSS Variable Support With JavaScript? The latest version of Firefox has support for CSS Variables… How To Replace Text With Jquery? Is it possible I can replace my name with 'anonymous… Trying To Make Navigation Bar For Tablet Site I'm designing a navigation bar for a tablet website. Th… December 2024 (1) November 2024 (38) October 2024 (65) September 2024 (22) August 2024 (220) July 2024 (194) June 2024 (444) May 2024 (702) April 2024 (443) March 2024 (883) February 2024 (912) January 2024 (833) December 2023 (897) November 2023 (392) October 2023 (554) September 2023 (306) August 2023 (334) July 2023 (276) June 2023 (399) May 2023 (229) April 2023 (126) March 2023 (149) February 2023 (174) January 2023 (288) December 2022 (130) November 2022 (223) October 2022 (173) September 2022 (172) August 2022 (494) July 2022 (309) June 2022 (324) Menu Halaman Statis Beranda © 2022 - JavaScript General