Jquery select events

i am working with a select. I want to trigger and event when the user select a value.

I am using the event "change", the problem is that if a user open the select but choose the same option that is selected, the triggers doesn't fire.

Is there a way to capture the event when a user select an option independently if the option is the same than is the one that was selected?


-------------Problems Reply------------

I'm not sure whether it's a cross-browser solution but something like this:

$("#mySelect option").click(function() {
// do sth

Works well in Opera/Firefox.

You can catch both the change and click events using the bind method. This should allow you to catch most keyboard and mouse interactions

$('selector').bind('click change',function() {})

I think the option you need is "click" instead of change.

I'm not sure this is what you need. It is not the answer but a trick.

In my case, i change the value of select box after get value of it.

$("selector").on('change', function() {
var selectedValue = $(this).val().trim();
if (selectedValue == 'EXPECTED_VALUE') {
//do somethings
//change the value, so next time when you choose same option
//again the change event can be trigger

The OTHER_VALUE may be is EXPECTED_VALUE with an extra space. Example: EXPECTED_VALUE = 'foo' then OTHER_VALUE = 'foo '. So you get same value when you get selectedValue by

var selectedValue = $(this).val().trim();

I just want to comment but i have not enough reputation :D


if($(this).val() == "week"){
//trigger here
<select id="selectID">

Category:jquery Views:1 Time:2010-03-12
Tags: jquery

Related post

  • how to select text with the jquery-select-event inside a div element? 2012-01-12

    is it possible to throw the jquery-select() event on a text which is inside a div element? here is my example but it doesnt work. <div id='id1'>Hello text</div> $("#id1").select( function () { alert("something was selected"); }); My goal

  • jQuery autocomplete UI Widget- Perform jQuery select event on dynamically created table row element 2011-08-30

    I have a working jQuery autocomplete being performed on the text input of a table data element, txtRow1. The text data is remote, from a mysql database, and is returned by JSON as 'value' for the text input. The returned data includes another piece o

  • jQuery Selectable Events 2011-12-08

    I have a jQuery plugin that drags and drops elements into different containers, I want to attach some events, for example when an element is over a container. These events used to work perfectly but then they stopped working. for Some reason the Sele

  • jquery select event handler for combobox 2012-03-24

    I'm using Daniel Ferell's Combo Box for bootstrap https://github.com/danielfarrell/bootstrap-combobox which works great but, it disables the normal select method behavior. How can I still track the selection after something has been choosen? Ie norma

  • JQuery UI; Stop propagation of selectable events 2009-11-12

    Basically I am using jQuery ui's selectable functionality on a ul, but the ul will often times have a scrollbar, and this scrollbar becomes unusable in Webkit browsers since when you try to click on it to grab it, the lasso for the selectable functio

  • jQuery - trapping tab select event 2010-09-04

    I'm a jQuery noob and I'm trying to figure out how to trap the tab selected event. Using jQuery 1.2.3 and corresponding jQuery UI tabs (not my choice and I have no control over it). It's a nested tab with the first level div name - tabs. This is how

  • jQuery: "change" event on file input element does not fire if the file selection is triggered by an element other than the file input 2010-11-10

    RE: Jquery: change event to input file on IE Any alternative to jQuery change() to detect when user selects new file via dialog box in IE8? The above questions dealt with getting the 'change' event to fire consistently across browsers after a file se

  • Select event on JQuery UI autocompleter is not fired 2010-11-21

    I am trying to use the jQuery UI, but I can't seem to figure out how to get the select event to execute. I bind the autocompleter as following: $().ready(function () { $("#txtPersonSearch").autocomplete({ source: '<%=Url.Action("GetPeople") %>'

  • jquery: select text event 2010-12-06

    is it possible that when user selected some text(non textarea nor input), jquery can call my callback to let me know which div's text is selected, and if the select focus is lost also call my callback? Thanks. --------------Solutions------------- Som

  • Capturing jQuery change event repeatedly for select on same index 2011-01-24

    There is a neat little feature in jQuery (or the browsers, I'm not sure anymore) that, when you use the keyboard to navigate a select element, makes sure the jQuery "change" event does not retrigger when you press enter multiple times. This is all go

  • jQuery .change() event doesn't fire on select list from keyboard: how can I override this? 2011-02-17

    The jQuery .change() event doesn't fire the second time the user types and presses Enter to select an item. It does fire the first time. See: http://jsfiddle.net/CtXbU/ If you focus on the list and type AD and press Enter, [EDIT] the alert fires. But

  • Select element and jQuery CHANGE event in IE8? 2011-02-25

    I have a small script on my site that calculates a price quote based on the options chosen in 4 different Select elements. The price quote is written into a div and is updated each time there is any change in the selected options. Here is the link to

  • JQuery UI Tabs: how to change selected tab from callback, supplied to 'select' event? 2011-08-21

    I use JQuery UI tabs, and I've attached a callback function to the select event, and I want to change selected tab from within this function: $('#tabs').tabs({ select: funciton () { // here I have to change the tab, that have been just selected, to a

  • jQuery UI autocomplete select event not working with mouse click 2011-09-06

    I have a list of links, and I have this search box #reportname. When the user types in the search box, autocomplete will show the text of the links in a list. <div class="inline"> <div class="span-10"> <label for="reportname">Report

  • jquery UI tabs select tab without triggering the select event 2011-10-05

    I'm a complete newb to jquery so sorry in advance if im speaking jibberish. What I want to do is programatically select a tab in javascript on pageload without triggering the selected event. The selected event does a postback to the tabitems url, so

  • Firing the select event on click for jQuery autocomplete 2011-11-16

    After playing around with jQuery's autocomplete feature a bit, I couldn't get the select event to fire onclick. Which is strange because the onfocus event fires when the mouse is dragged over each element in the list. From what I've tried so far, it

  • jQuery - text field value change after jquery auto complete select event 2012-05-01

    Simple text field change after jquery auto complete select event. I want to split the data and display it in other text fields. I am trying this. This doesn't change any values at all. What do I need to change here? $(function() { $("#term").autocomp

  • Global event if a jQuery selection returns no elements? 2010-03-03

    Is there any way to globally monitor or listen to if a selection is made in jQuery and it returns no elements? E.g.: You have a page with: <div id=”some-id”></div> And in a JavaScript someone tries to get the element but mistypes the id:

  • How to force 'select' event in jQuery Tabs if tab already selected? 2010-12-01

    The main issue is that if tab is already selected the 'select' event doesn't fire if i set the same tab id again. The reason i required in this to update the content located in the tab. I need a way to fire 'select' even if i specify already selected

Copyright (C) dskims.com, All Rights Reserved.

processed in 0.173 (s). 11 q(s)