How to get actual content of an object after being replaceWith('something') in jquery?

Your updated method is the correct one, just needs a tweak like this: $('. Selector'). Click(function(){ var obj = $(this), repl = $('whats up man?!

'); obj. ReplaceWith(repl); alert(repl. Find('span').

Attr('class')); //this will print 'undefined' }) You can test it out here The important change is the repl.find() to look in the new element instead of the old one.

Your updated method is the correct one, just needs a tweak like this: $('. Selector'). Click(function(){ var obj = $(this), repl = $('whats up man?!

'); obj. ReplaceWith(repl); alert(repl. Find('span').

Attr('class')); //this will print 'undefined' }); You can test it out here. The important change is the repl.find() to look in the new element instead of the old one.

1 thx nick, you nailed it. – mdennisa Aug 27 '10 at 3:06.

You know what you replaced it with.... $(document). Ready(function(){ $('. Selector').

Click(function(){ var obj = $(this); var replacement = $('whats up man?!'); obj. ReplaceWith(replacement); alert(replacement.html()); }); }).

Thx andrew, my intention is to have access to manipulate everything inside the actual 'obj', $('. Size'). Click(function(){ var obj = $(this), repl = $('whats up man?!

'); obj. ReplaceWith(repl); alert(obj. Find('span').

Attr('class')); // this will print 'undefined' // I want to get the class name from the actual 'obj' }); – mdennisa Aug 26 '10 at 9:28 but you know you just assigned size to it, so why aren't just just alerting size? Just do: replacement. Find('span').

Attr('class') if you really must – Andrew Bullock Aug 26 '10 at 9:35 yes andrew, your code has solved my question in the first place. But I think I missunderstood. Here is the final result jsfiddle.

Net/HCXaK/1 – mdennisa Aug 27 '10 at 3:20.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions