Home >Web Front-end >JS Tutorial >Three ways to read data from the database and output it into html tags_javascript skills

Three ways to read data from the database and output it into html tags_javascript skills

WBOY
WBOYOriginal
2016-05-16 16:34:192056browse

Maybe many people do not need to convert the data into html tags when reading data from the database, but maybe one day you will find that when we need to output it into html tags, the compiler automatically outputs it into a string for us. This is us You can do it this way

Method 1:

The most common method, use JS or JQ

JQ:

$("#div").html("45a2772a6b6107b401db3c9b82c049c2I am HTML code54bdf357c58b8a65c66d7c19c8e4d114");

JS:

var dobj=document.getElementById("div");
dobj.innerHTML = "<span>我是HTML代码</span>";

Method 2:

When you find that the data read from the database cannot be used by the above two methods, you can try it

$("#div").html(“@Html.Raw(我是数据库中的HTML代码)”);
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn