Using JQuery to get text of a div that's a child of a header to replace a different header
Posted
by Stevie Jenowski
on Stack Overflow
See other posts from Stack Overflow
or by Stevie Jenowski
Published on 2010-05-16T01:56:34Z
Indexed on
2010/05/16
2:00 UTC
Read the original article
Hit count: 256
Hello all, I'm trying to get the text contents of a .div('.child#') child of my event.target('h6.class'), and replace my other headers('h1.replacHeader#') using this script below...
$('h6.class').click(function(event) {
var $target = $(event.target);
$('.replaceHeader1').replaceWith("<h1 class='replaceHeader1'>" + $target.children(".child1").text() + "</h1>");
$('.replaceHeader2').replaceWith("<h1 class='replaceHeader2'>" + $target.children(".child2").text() + "</h1>");
});
});
I've noticed that .text() apparently doesn't apply to an event.target... So how could I go about achieving this?
© Stack Overflow or respective owner