// Find correct element
const el = document.querySelector(".js-property-select.selected");
// Create new tag-indicator
const newElement = document.createElement('div');
newElement.className = "tag-indicator";
// Append to active element
el.appendChild(newElement);
// Optional; remove it
const toRemove = el.querySelector(".tag-indicator");
el.removeChild(toRemove);
.tag-indicator {
height: 10px;
border: 1px dotted orange;
}
<ul id="property-select-list">
<li class="js-property-select" data-id="1" data-has_media_alt="YES">
prperty1
</li>
<li class="js-property-select selected" data-id="2" data-has_media_alt="NO">
prperty2
<div class="tag-indicator"></div>
</li>
<li class="js-property-select" data-id="3" data-has_media_alt="NO">
prperty3
<div class="tag-indicator"></div>
</li>
</ul>
Примечание. Я добавил css к .tag-indicator
, чтобы сделать их видимыми.
JQuery // Add
$('.js-property-select.selected').append('<div class="tag-indicator"></div>');
// Optional; Remove
$('.js-property-select.selected > .tag-indicator').remove();
.tag-indicator {
height: 10px;
border: 1px dotted orange;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<ul id="property-select-list">
<li class="js-property-select" data-id="1" data-has_media_alt="YES">
prperty1
</li>
<li class="js-property-select selected" data-id="2" data-has_media_alt="NO">
prperty2
<div class="tag-indicator"></div>
</li>
<li class="js-property-select" data-id="3" data-has_media_alt="NO">
prperty3
<div class="tag-indicator"></div>
</li>
</ul>