0

I want to create animation placeholder for input and select element.

I use a label block on select element at first as a placeholder, then click the label or select element , in ideal, the label will move to top as a title, and select element will show its options.

However, just when I click the area of select element but outside the label will action as I though; if I clicked the label, it would just move to top but not show select element's options. It should click select element again to show options.

So, I want to trigger select element by these method as following but not working...

$(document).on('click', '.moveable-disabled-option', function() {
    $(this).prev().trigger('click');
    $(this).prev().trigger('focus');
    $(this).prev().focus();
})

My Demo: https://codepen.io/hsieh-po-yang/pen/yLOodyN

  • As I understand what you're asking, you're trying to open the `select` via javascript? Doesn't seem to be possible; see this link for details (and numerous duplicates it links to) https://stackoverflow.com/questions/19652085/open-dropdown-list-from-javascript-function – freedomn-m Sep 01 '20 at 17:22
  • You can't trigger the default ` – VVV Sep 01 '20 at 17:28
  • Thanks for answering my question, I'll try the other method! – Po-Yang Hsieh Sep 05 '20 at 13:05

0 Answers0