SamotnyPocitac
SamotnyPocitac

Reputation: 402

jQuery append and prepend dilema

I'm trying to append a <p> tag to a div element. The problem is that I need to hide the div element but not the appended <p> tag. Somehow prepend it before or after. What can I do?

<div id='vid1'></div>


$('#vid1').append('<p class="ytclick">text</p>');
$('#vid1').hide();

Demo

Upvotes: 0

Views: 34

Answers (1)

Denys S&#233;guret
Denys S&#233;guret

Reputation: 382474

You can't have a visible element in a hidden one.

You should probably use before or after :

$('#vid1').after('<p class="ytclick">text</p>');

Upvotes: 2

Related Questions