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 950717
In Process

The Archive Base Latest Questions

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

I have the following HTML containing a drop down list (single selection) <script type="text/javascript">

  • 0

I have the following HTML containing a drop down list (single selection)

        <script type="text/javascript">
            $(document).ready(function () {
                $("#garden").bind('change', function() {
                    alert("Changed");
                    });
            });
        </script>
    <body>
        <div id="content">  
           <select id="garden">
             <option value="flowers">Flowers</option>
             <option value="shrubs">Shrubs</option>
             <option value="trees">Trees</option>
             <option value="bushes">Bushes</option>                 
           </select>
        </div>
    </body>
</html>

When the HTML page is rendered, Flowers is the already selected element in the drop-down by default (being the first one). If I select any other value (other than "Flowers"), the Javascript function is fired and a alert box containing "Changed" is shown.

Q1: But, in case I re-select Flowers again, the onchange event is not triggered. I understand it is because nothing was ‘changed’ in the drop-down list. Is there a way a function is triggered even when no change to the already selected value in drop-down is done?

Q2: How to extract the value of the element which has just been selected (even if nothing new was selected – that is, user clicked on the drop down, and simply clicked somewhere else).

I have already tried the onblur but that requires that the user clicks somewhere else on the document so that the drop-down loses focus. Any help would be really appreciated.

[I have edited out the HTML headers and other script inclusions in the code snippet provided for brevity.]

  • 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-15T23:36:47+00:00Added an answer on May 15, 2026 at 11:36 pm

    Well I think I don’t get you 100%, but some things I can suggest here are:

    • bind a click event handler to the select

      $("#garden").bind('click', function() {
           alert($(this).find('option:selected').text());
      });
      
    • bind a focusout event handler

      $("#garden").bind('focusout', function() {
           alert($(this).find('option:selected').text());
      });
      

    and of course bind the change event handler which you already got. The click event handler might be a little bit tricky since it would fire every time you click on the element. But if you don’t alert() it every time it should not be a problem at all, you got the current selection and can do with it whatever you want.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 513k
  • Answers 513k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer select OBJECT_DEFINITION(OBJECT_id('sysmail_faileditems')) AS [processing-instruction(x)] FOR XML PATH('') Shows sysmail_faileditems definition… May 16, 2026 at 5:49 pm
  • Editorial Team
    Editorial Team added an answer You could use a CouchDB show function to set the… May 16, 2026 at 5:49 pm
  • Editorial Team
    Editorial Team added an answer Use the DBEngine.CompactDatabase method instead of JetComp. One less thing… May 16, 2026 at 5:49 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

I have following page <html> <head> <script type=text/javascript src=e01.js></script> </head> <body> <script type=text/javascript> var
Suppose I have following html page. <html> <head> <link type=text/css rel=Stylesheet href=css/some.css /> </head>
I have the following HTML: <tr id=n16> <td class=t_row>Text <a href=# onClick=javascript:notification_dismiss('16');>Dismiss</a></td> </tr> I
I have the following HTML with Javascript: <A HREF=javascript:void(0)onclick=window.open('http://www.msn.com/','New Windows','height=380, width=300,location=no')>Hide Address Bar</a> It's
I have the following html code: <table> <tr> <td> <div id=fixmywidth style=position:relative; height:30px;> <div
I have the following HTML: <div style=width: 143px; height: 125px; overflow: scroll;><select size=20 style=min-width:
I have the following html on page along with other code on the page.
I have the following HTML (excerpt from larger code-base) <div class=diary-event ui-corner-all title=[title]> <span
I have the following HTML structure: <div><a href=link1>blah</a></div> <div><a href=link2>blah</a></div> <div><a href=link3.swf>blah</a></div> <div><a href=link4>blah</a></div>
I have the following HTML code: <div style=background-image:url(~/Images/MyImage.jpg); width:100%; height:100%> I'm not too familiar

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.