我有这个代码
$(document).ready(function(){
$('.selector').click(function(){
obj = $(this);
obj.replaceWith('<div class="size">whats up man ??!</div>');
alert(obj.html());
});
});
Run Code Online (Sandbox Code Playgroud)
我想获得'obj'的新内容,这个内容一直是'replaceWith'
但,
我得到旧内容而不是......
我怎样才能得到'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'
});
Run Code Online (Sandbox Code Playgroud)
我想要打印'span'的类名称'medium'