First Child Does Not Work With My Selector
my js $('dd:first-child', 'dd:first-child(2)').remove(); consider my markup is like this
why it doesn't work?
why it doesn't work?
Solution 1:
That is because first-child(2)
is not a function so it will give an error.
It should be:
$('dd:first-child, dd:eq(1)').remove();
or
$('dd:eq(0), dd:eq(1)').remove();
or
$('dd:nth-child(1), dd:nth-child(2)').remove();
This might also work:
$('dd:lt(2)').remove();
Edit:
To delete the <br>
you can do:
$('dd br:lt(2)').remove();
Post a Comment for "First Child Does Not Work With My Selector"