0

I have select with long text options and I need to slice that text to 30 chars and add three dots at the end when option is selected. I need it like this just to be displayed in select box. When another select is made first option should appear in options as it was, without slice. With code below when I select option it stays sliced when select is made, until I refresh the page. How to restore original text, without slice, when another option is selected?

$("select").on("change", function(){
  var optionSelected = $("option:selected").text();
  var sliced = optionSelected.slice(0,30);
  $("select option:selected").text(sliced+"...");
});

It's a design thing. I know this is not needed in most cases.

jakob
  • 3,265
  • 4
  • 23
  • 40

0 Answers0