Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    Regular Coder
    Join Date
    Jun 2006
    Location
    UK
    Posts
    922
    Thanks
    302
    Thanked 3 Times in 3 Posts

    Question Getting selected dropdown text

    Hi

    I have 5 dropdowns on my webpage. What I want is when any of the options from any dropdowns are selected, i should be able to alert the text of it (not the value). I am trying the following code but it does not display any result.


    Code:
    $(document).ready(function(){
    
        $('select').change(function(){
    
             alert( $(this + '  option:selected' ).text() );
    
        });
    
    });

    Pls help

  • #2
    Senior Coder
    Join Date
    Dec 2010
    Posts
    2,398
    Thanks
    12
    Thanked 570 Times in 563 Posts
    Try this
    Code:
    alert( $(this).find('option:selected').text() );


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •