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
Release: 2016-05-16 16:34:19
Original
2055 people have browsed it

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("I am HTML code");

JS:

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

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代码)”);
Copy after login
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template