Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

To reset the value of select2 and display the placeholder again, you can use the following steps:

  1. Get the reference to the select2 element:
var selectElement = $('#yourSelectElement');
  1. Use the val() method of the select2 element to set its value to null and trigger the change event to update the UI:
selectElement.val(null).trigger('change');
  1. Use the attr() method to set the placeholder attribute value of the select2 element to the desired placeholder text:
selectElement.attr('placeholder', 'Your placeholder text');

By following these steps, you can reset the value of select2 and display the placeholder again.