_mercury
_mercury10mo ago

✅ – ✅ – _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()...
Jump to solution
4 Replies
_mercury
_mercury10mo 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
_mercury
_mercury10mo ago
this works if anybody interested (e.target).next().text()
reactibot
reactibot10mo ago
This question has an answer! Thank you for helping 😄 If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1159965298858926091
reactibot
reactibot10mo ago
This question has an answer! Thank you for helping 😄 If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1159965298858926091 This thread hasn’t had any activity in 36 hours, so it’s now locked. Threads are closed automatically after 36 hours. If you have a followup question, you may want to reply to this thread so other members know they're related. https://discord.com/channels/102860784329052160/565213527673929729/1159965298858926091