I have an html structure as shown below also have AJAX API which refresh the span inside the third div asynchronously. I want to check the content of span inside div3
repeatedly which is added dynamically by API. If it contains 'Hi' I want to display image inside div3
otherwise display nothing.
<div id="div1">
<div id="div2">
<div id="div3">
<span>Hi</span>
</div>
</div>
</div>
<script type="text/javascript">
$(function(){
(function loopsiloop(){
setTimeout(function(){
var tmp = $('#div3').find("span").val();
if(tmp=='hi'){
document.getElementById("myChatLinkInfo").innerHTML ='<img src="http://slovnikonline.com/img/hi-ohio-logo.jpg">';
}
loopsiloop();
},4000);
})();
loopsiloop();
});
</script>