I have a nav here with li inside is an anchor tag and span which consist of the text. What I want to achieve is to replace all span in the nav using jquery replaceWith however, I can't seem to make it work. This is the code I made. Any Idea what my error is?
<script>
$( document ).ready(function() {
//store img in an array.
var imgArray= [ "<img class=\"imgNav\" src=\"https://irp-cdn.multiscreensite.com/abc3fe9a/dms3rep/multi/services_icon_1-123x123.png\"/>",
"<img class=\"imgNav\" src=\"https://irp-cdn.multiscreensite.com/abc3fe9a/dms3rep/multi/services_icon_4-123x123.png\"/>","<img class=\"imgNav\" src=\"https://irp-cdn.multiscreensite.com/abc3fe9a/dms3rep/multi/services_icon_66-123x123.png\"/>" ];
$('.dmUDNavigationItem_010101661768 > span.navItemText').replaceWith(imgArray[0]);
$('.dmUDNavigationItem_010101628177 > span.navItemText').replaceWith(imgArray[1]);
/* if I put this third one in the script it doesn't work.
$('.dmUDNavigationItem_010101420041 > span.navItemText').replaceWith(imgArray[2]);
*/
});
</script>
This is my HTML link in jsbin. http://jsbin.com/magofarivi/edit?html,output