私は何かばかげたことをしているに違いありませんが、これを理解することはできません。なぜこのスクリプトは、<p>
タグからのテキストを console.log(ing) しないのですか?
HTML:
<div>
<label>Display Name:</label>
<div>
<p>The room that its in.</p>
<span class="edit"></span>
</div>
</div>
jQuery:
if ($('span.edit').length > 0) {
$(this).click(function(){
var elem = $(this).prev();
var text = elem.text();
console.log(text);
elem.html('<input type="text">' + text + '</input>');
});
}