Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 946609
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T22:56:46+00:00 2026-05-15T22:56:46+00:00

I have a HTML select list, which can have multiple selects: <select id=mySelect name=myList

  • 0

I have a HTML select list, which can have multiple selects:

<select id="mySelect" name="myList" multiple="multiple" size="3">
   <option value="1">First</option>
   <option value="2">Second</option>
   <option value="3">Third</option> `
   <option value="4">Fourth</option> 
   ...
</select>

I want to get an option’s text everytime i choose it. I use jQuery to do this:

$('#mySelect').change(function() {
   alert($('#mySelect option:selected').text());
}); 

Looks simple enough, however if select list has already some selected options – it will return their text too. As example, if i had already selected the “Second” option, after choosing “Fourth” one, alert would bring me this – “SecondFourth”. So is there any short, simple way with jQuery to get only the “current” selected option’s text or do i have to play with strings and filter new text?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T22:56:46+00:00Added an answer on May 15, 2026 at 10:56 pm

    You could do something like this, keeping the old value array and checking which new one isn’t in there, like this:

    var val;
    $('#mySelect').change(function() {
     var newVal = $(this).val();
     for(var i=0; i<newVal.length; i++) {
         if($.inArray(newVal[i], val) == -1)
           alert($(this).find('option[value="' + newVal[i] + '"]').text());
     }
     val = newVal;
    }); ​
    

    Give it a try here, When you call .val() on a <select multiple> it returns an array of the values of its selected <option> elements. We’re simply storing that, and when the selection changes, looping through the new values, if the new value was in the old value array ($.inArray(val, arr) == -1 if not found) then that’s the new value. After that we’re just using an attribute-equals selector to grab the element and get its .text().

    If the value="" may contains quotes or other special characters that would interfere with the selector, use .filter() instead, like this:

    $(this).children().filter(function() {
      return this.value == newVal[i];
    }).text());
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.