I am trying to get a line through the li that i added when i click the li(like a grocery list).
$('document').ready(() => {
let id = 1;
$('.knop').click(() => {
let boodschap = $('.tekst').val();
let newli = `<li id="boodschap${id}"> ${boodschap}</li>`;
$(".result").append(`${newli}`);
id++;
});
$('ul').click(() => {
let target = event.target.id;
$(`${target}`).css({
"text-decoration": "line-through"
});
console.log(event.target.id);
});
});
I know the problem is in this part:
$('ul').click(() => {
let target = event.target.id;
$(`${target}`).css({
"text-decoration": "line-through"
});
I dont get a error in my console. so im stuck. but when i hard code the part where i put my ${target} it works. you cant use a variable in the css function? is there a way around this?