I am working with a simple project which requires modification of the html source code with some logic and then display the modified html source code into a div when a button is clicked.
The Output before modification is when i click the Show html
When i click the Show converted html the output is like
What i basically want to do the modification for inner children whatever may be the depth of child nodes. What is happening here the modification is done at a single level i.e span and h1 tag is eliminated.
Show html button display the content of external html file rather than source code of the page.The code for converting the source code of external html file is like
<script>
function convertHtml() {
$body = $("#demo").text();
$fakediv = $("<div></div>");
$fakediv.html($body);
$fakediv.children().each(function(){
$thisText = $(this).text();
if($thisText)
$(this).text("@"+$thisText+"@")
});
$("#demo").text($fakediv.prop("outerHTML")); //fill in the div with converted html string
}
//Document is ready to execute the JS
$(document).ready(function() {
$("#convert").click(function(){
// alert($("#demo").text());
convertHtml();
});
});
</script>
Please help.
Thanks!