私はこのコードを持っています
$(document).ready(function(){
$('.selector').click(function(){
obj = $(this);
obj.replaceWith('<div class="size">whats up man ??!</div>');
alert(obj.html());
});
});
'replaceWith'である'obj'の新しいコンテンツを取得したい
しかし、
代わりに古いコンテンツを取得します...
'obj'の実際のコンテンツを取得するにはどうすればよいですか?
私の意図は、新しい「obj」にアクセスすることです
$('.selector').click(function(){
var obj = $(this),
repl = $('<div class="size">whats up man ??! <span class="medium"></span></div>');
obj.replaceWith(repl);
alert(obj.find('span').attr('class')); //this will print 'undefined'
});
'medium'である'span'のクラス名を出力したい