It is necessary that when you select an element in the select tag, js handles the event. Now I do it through blur, but for this it is necessary that the user has shifted the focus to some area after the selection, which is not very beautiful. So I think, maybe there is some property that when selecting a select automatically shifted the focus to another element.

  • Can I somehow check js before building? if ($ ('# cat'). val ()! = '') $ ('# cat'). val () = ''; - Radik Kamalov

1 answer 1

If on jQuery, it's very simple:

$('select').change(function(){ alert('Произошел выбор в select-е'); // меняем на смещение фокуса }) 

On pure js more difficult, read here in more detail .

  • one more question in a cape) When choosing one of the selects, js is triggered and new elements appear in the HOUSE. When the page is reloaded, the selection is saved in the cache, and accordingly. js does not work. How to solve this problem? - Radik Kamalov
  • Is the selection of the select stored in the cache? What is it like? When you reload the page, all entered values ​​are usually lost if you have not applied tricks. - Zhukov Roman
  • @ Radik Kamalov, you accept the answer, then you shoot only because you wanted to ask something else ... I would be in the place of @Zhukov Roman, I would just ignore you. - Deonis
  • on-p user sent the form, and came back. firefox keeps the last selection. - Radik Kamalov
  • If you cannot distinguish the reboot from the action "back", then you had better start ... @Deonis, where should he start, tell me? :) - Zhukov Roman