selecteditem - Getting previously selected item in select box with jQuery -
I have an item HTML selection box, on which I want to know what was selected before changing the item Selection of items.
Until the change is removed, it is too late:
$ ("select"). Change (work () {var str = ""; $ ("select option: selected"). Each (function () {// This is the current selected item (new) str + = (this) .text () "Docs" Docs says that 'The change event sets a fire when a control input loses focus and its focus is revised by obtaining a focus . '
However, the 'blurred' event does not seem to be the perfect organizing event and there is no incident of "onFocusLost" type.
Is it a cross- a lot of hoop jumping Browser compatible ways without?
The value should be captured before this change as soon as the user opens the selection menu, Will be caught, but in reality they choose something before they.
$ (document) .ready (function () {$ ('select'). Focus (function () {var theValue = $ (this) .attr ('value');} );});
Comments
Post a Comment