I have the following:
$('.select-topic').click(function () {
if ($(this).attr('data-list') == "N") {
$(this).attr('data-list', 'Y')
var topicSelectHtml = $('#TopicID').html();
$(this).html(topicSelectHtml);
$(this).attr('data-clicked', 'Y')
}
When a user clicks on a new topic then it takes the $('#TopicID').html(); and uses this as the html for topicSelectHtml.
This works but what I need to do is to remove a section of the $('#TopicID').html(); that's not required for the new select. Here is my select html:
<select name="TopicID" id="TopicID"><optgroup label="Admin">
<option value="00">All Topics</option>
<option value="050002">Classes</option>
</optgroup>
xxxxxxxxx</select>
How can I remove the <optgroup label="Admin"> ... </optgroup> section? Note there are no line feeds in my html.