どちらが好ましい方法であり、その理由は何ですか?
方法1:
<p>When I'm clicked, add an image under me.</p>
<img src="/path/to/image.gif" />
$('p').hide(); // OR css display:none
$('p').click(function() {
$('img').show();
});
方法2:
<p>When I'm clicked, add an image under me.</p>
$('p').click(function() {
$('<img src="/path/to/image.gif" />').appendTo('p');
});