[英]How to convert a string with an HTML code into a working HTML code (in Ruby or Javascript)?
[英]Link shows as string instead of HTML code - How to convert to HTML using JavaScript
I think you just need to create an new div
tag at where you want to place that text, and then you just append that text into the div
you just created, by using append()
function if you are using jquery, and .innerHTML()
如果只有 javascript
Are you sure!
<div id="text">
// your text is gonna here
</div>
<script>
const item = card.imgURL
? `<img src="${card.imgURL}">`
: card.text
document.getElementById('text').innerHTML += item;
</script>
我希望它會有所幫助
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.