Reputation: 237
I have this html code:
<div id="step-1st">
<pre style="display:none"></pre>
<textarea></textarea>
</div>
I like to remove textarea
and show the pre
with the below code:
$("#step-1st textarea").remove().parent().children("pre").show();
Surely this can be done easily with more than on line, but i want to know how to do so with one line.
Upvotes: 0
Views: 71
Reputation: 7199
This should do it.
$("#step-1st pre").next().remove().end().show();
There are many ways to do it, but you are most likely going to need to use .end()
to get back to the original selector.
Upvotes: 1
Reputation: 74420
if you have more than one <pre>
elements:
$("#step-1st textarea").parent().children("pre").show().end().end().remove();
Upvotes: 1