I am trying to modify the text in the parent div from child div without changeing the child div contents.
I have
<div id='testDiv'>
this is the test parent div
<div id='child1'>
lots of contents and child div
...................
</div>
more div/child div and contents...
</div>
in my jquery
$('child1 div a').click(function(){
$('#testDiv').text('new text'); //this will remove the child1 div and all the contents inside testDiv
//I want to replace 'this is the test parent div' text to 'newt text'
})
Are there anyways to get this done? Thanks a lot!
If you wrap the text in a span, it would be easier to change it:
FIDDLE
You could ofcourse unwrap the textnode once it’s changed if the span element causes some sort of problem?