The initially selected options retain the HTML tags, once you select a different option it removes the HTML tags from the selected option and just copies the text inside the tags by using the text() method. So, I have changed text() method to html().
The initially selected options retain the HTML tags, once you select a different option it removes the HTML tags from the selected option and just copies the text inside the tags by using the
text()
method. So, I have changedtext()
method tohtml()
.