skip to Main Content

Html – Calling markdownit() for a dynamically loaded div

<!doctype html> <html> <head> <script src="https://cdnjs.cloudflare.com/ajax/libs/markdown-it/13.0.1/markdown-it.min.js" integrity="sha512-SYfDUYPg5xspsG6OOpXU366G8SZsdHOhqk/icdrYJ2E/WKZxPxze7d2HD3AyXpT7U22PZ5y74xRpqZ6A2bJ+kQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script> window.onload = function() { var md = window.markdownit(); var div = document.getElementsByClassName('markdown'); for(var i = 0; i < div.length; i++) { var content = div[i].innerHTML; document.getElementsByClassName('markdown')[i].innerHTML = md.render(content); } }…

VIEW QUESTION
Back To Top
Search