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.HeaderToBeClicked').click(function(event) {
var $target = $(this);
$('.replaceHeader1').replaceWith("<h1 class='replaceHeader1'>" + $target.children(".child1").text() + "</h1>");
$('.replaceHeader2').replaceWith("<h1 class='replaceHeader2'>" + $target.children(".child2").text() + "</h1>");
});
});
HTML:
<div id="ReplaceTheseHeaders">
<h1 class='replaceHeader1'></h1>
<h1 class='replaceHeader2'></h1>
</div>
<div id="accordian" class="acc">
<?php $counter = 1; ?>
<?php foreach ($tmpl->vars as $var) { ?>
<h6 class="HeaderToBeClicked"><a href="#">
<div class="counter"><?php print $counter . "." ?></div>
<div class="child1"><?php print $var['title'];?></div>
<div class="child2"><?php print $var['name'];?></div>
</a></h6>
<?php $counter = $counter+1; ?>
<?php } ?>
</div>
I've noticed that .text() apparently doesn't apply to an event.target... So how could I go about achieving this?