html - jquery dynamic strike not working

问题描述:

So I am inserting dynamically a strike element, but it is rendering in the HTML markup but not showing up visually. The Chrome inspector shows that the strike element is added. Is it because I am adding it around input elements?

Here's the jQuery

$("#ResidentialStandardPeriod").change(function () {

period = $("#ResidentialStandardPeriod").val();

console.log(period);

if (period == $('#' + period).attr('id')) {

$('#' + period).attr('disabled', true).wrap("<strike>")

$('input[type=checkbox]').not('#' + period).attr('disabled', false);

}

});

网友答案:

You can't wrap input element with </del>, coz that wont show any effect on input
but you can wrap next element, in your case number.
I would prefer you to wrap your number in <span> and then target that span.