✅ – ✅ – _mercury – 21-27 Oct 6

let prodState = [];
function populateProductState(tag) {
$(".product-state-tags").empty();
prodState.forEach((tag) => {
if (tag.trim() !== "") {
$("ul.product-state-tags").append(`
<li >
<span class="delete-tag" >x</span>

<span class="m-1 p-1 tag-value">${tag}</span>
</li>
`);
}
});
$(".product-state-input").val("");
}
let prodState = [];
function populateProductState(tag) {
$(".product-state-tags").empty();
prodState.forEach((tag) => {
if (tag.trim() !== "") {
$("ul.product-state-tags").append(`
<li >
<span class="delete-tag" >x</span>

<span class="m-1 p-1 tag-value">${tag}</span>
</li>
`);
}
});
$(".product-state-input").val("");
}
how to get the text value of the .tag-value value when clicking .delete-tag span ? using jquery
Solution:
this works if anybody interested (e.target).next().text()...
M
_mercury195d ago
// del tag
$("body").on("click", ".delete-tag", (e) => {
const v = $(this).closest("span.tag-value").text();
console.log(v);
});
// del tag
$("body").on("click", ".delete-tag", (e) => {
const v = $(this).closest("span.tag-value").text();
console.log(v);
});
this does not work undefined
Solution
M
_mercury195d ago
this works if anybody interested (e.target).next().text()
UU
Unknown User193d ago