JavaScript JavaScript: Make <select onchange> or <option onclick> keyboard-accessible javascript make select readonly,javascript make select required,javascript make

Similar questions have been asked before, but I'm looking for the "opposite" solution than all the others ;-)

I need a JavaScript event that fires when a user decides for an option in a select field.

What do I mean by decide:

  • Mouse: Click to expand the select, then click to select any option.
  • Keyboard: Either:
    • Press the UP/DOWN keys to "scroll" through the options (without expanding the select), then press ENTER/TAB to select. Or:
    • Press ALT+DOWN to expand the select, then use the UP/DOWN keys to scroll through the options, and finally press ENTER/TAB to select.

Non-perfect solutions I've found so far:

  • onclick on each option: Firefox & Internet Explorer: Works for mouse, but not for keyboard. Chrome: Doesn't work at all.
  • onchange on the select: Firefox: Works as expected. Chrome & Internet Explorer: Fires too early when using just the UP/DOWN keys (without expanding the select): In the users' mind, they are just scrolling through the available options, not actually selecting anything yet.
    Albeit being popular, this approach violates WCAG: http://www.w3.org/TR/2012/NOTE-UNDERSTANDING-WCAG20-20120103/consistent-behavior-unpredictable-change.html
  • onblur on the select: Firefox & Chrome & Internet Explorer: Fires too late, only when actually leaving the select.
  • onkeydown on the select, plus evaluating the keyCode: Looks like a hassle to me, cause there might be (or turn out) other ways to confirm something than pressing the ENTER key (maybe on mobile devices).

The only solution I've found, having perfect accessibility, is ugly:

  • Having an explicit submit button and binding the event to this.

So (finally) my question is: Do you know any other way to achieve this without the submit button?

Answer:1

This is my CSS, in which, three keyframes are bound together to make a chain animation #anim-div{ -webkit-animation-name : mpbar-anim-page1, mpbar-anim-page2, mpbar-anim-page3; animation-...

This is my CSS, in which, three keyframes are bound together to make a chain animation #anim-div{ -webkit-animation-name : mpbar-anim-page1, mpbar-anim-page2, mpbar-anim-page3; animation-...

If a new ranking is clicked how can we automatically declick the previous click? <%= f.hidden_field(:ranking, id: 'ranking') %> <%= image_tag('4.png', data: { ranking: 4 }, class: 'image-...

If a new ranking is clicked how can we automatically declick the previous click? <%= f.hidden_field(:ranking, id: 'ranking') %> <%= image_tag('4.png', data: { ranking: 4 }, class: 'image-...

  1. addclass removeclass onclick
  2. addclass removeclass click

class helloworld { constructor(public message: string){} } var hello = new helloworld('hello vishal'); Console.log(hello.message); I am getting this error at Console.log statement you can see the ...

class helloworld { constructor(public message: string){} } var hello = new helloworld('hello vishal'); Console.log(hello.message); I am getting this error at Console.log statement you can see the ...

My script doesn't works when I use requirejs library to launch it. It's a simple game. After I click "start" program draws squares and when a green square appear the user has to click it as quick as ...

My script doesn't works when I use requirejs library to launch it. It's a simple game. After I click "start" program draws squares and when a green square appear the user has to click it as quick as ...

  1. javascript code works with alert
  2. javascript code only works in debug
  3. how javascript code works
  4. javascript code only works with alert
  5. javascript code doesn't work
  6. javascript code doesn't work in chrome
  7. javascript code won't work
  8. javascript code dont work
  9. how javascript code coverage works