I am trying to change the background colour of word in iframe tag. I am able to search the word, but not getting how to change the colour. Here is my code.
$(document).ready(function () {
$('#content').contents().find('head').append($("<style type='text/css'> .red{color:red;}</style>"));
var cont = document.getElementById('content').contentWindow.document.body.innerHTML;
if($("#content").contents().text().search("SEARCH WORD")!=-1){
console.log("Found");
//<span class="red"> SEARCH WORD </span>
}
})
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div style="padding-left: 0px;" class="col-sm-8 text-center">
<iframe id="content" ng-src="http://locahost:8888/public/textfiles/sample.txt"
width="100%" height="500px" align="middle"></iframe> 
</div>