As shown in the figure, why can't you see the option when the select, generated dynamically at the front end is selected?

 var fontSizeEl = $("<select size="4" class="form-control fontSize-select"></select>");
    fontSizeEl.append("<option value="10px">10</option>");
    fontSizeEl.append("<option value="14px">14</option>");
    fontSizeEl.append("<option value="16px">16</option>");
    fontSizeEl.append("<option value="20px">20</option>");    
    fontSizeEl.val(editor.getFontSize());
    fontSizeEl.click(function(e) { // 
        if (!$(e.target).hasClass("emotion")) {
          var size = $(e.target).val();
          editor.fontSize(size);
        }
    });
    $(this).append(fontSizeEl); // 
Apr.04,2021

Don't bind the click event to the current element, bind it to the parent or document


  1. if you use the native select/option to write this, the original style is more difficult to overwrite.
  2. but if the requirement is not high, you can simply cover it. For example, what you said should be caused by margin and so on.
  3. if you use the CSS library, it is recommended to check that some styles are assigned to option,. This should be due to the fact that there is no corresponding style assigned to you
  4. or write your own style using div
Menu