I have 2 p elements as follows
<p id="booking-sum-start"><span id="booking-sum-start-new"><span id="booking-summary-start-date"><?php echo $booking->start_date;?></span></span></p>
<p id="booking-sum-end"><span id="booking-sum-end-new"><span id="booking-summary-end-date"><?php echo $booking->end_date;?></span></span></p>
I have a date picker to select dates and i'm showing the selected dates as above. My approach is every time a user selects a date range i'm removing span element with id booking-summary-start-date and booking-summary-end-date and updating the span using .append method of jquery as follows.
let booking_start_date = document.getElementById("booking-summary-start-date");
let booking_end_date = document.getElementById("booking-summary-end-date");
booking_start_date.remove();
booking_end_date.remove();
let booking_start_date_container = document.getElementById("booking-sum-start-new");
let booking_end_date_container = document.getElementById("booking-sum-end-new");
booking_start_date_container.append(`<span id="booking-summary-start-date">${start_date}</span>`);
booking_end_date_container.append(`<span id="booking-summary-end-date">${end_date}</span>`);
here the removing part works but when appending it appends a string of for ex: ${start_date} instead of a span element.
How can i append the span element instead of a string ?
booking_end_date_container.appendto$(booking_end_date_container).appendand it will work fine (though I recommend using either vanilla javascript or jquery to remove these confusions). Example of the two: jsfiddle.net/oa7rne6hstart_dateandend_datehave a value.