Three ways to read data from a database and output it as HTML tags

  • 2020-03-30 04:07:56
  • OfStack

Maybe a lot of people don't need HTML tags to read data from a database, but maybe one day you'll see that when we need to output HTML tags the compiler will automatically output strings for us and that's how we can do it

Method 1:

The most common method is to use JS or JQ

JQ:

$(" # div "). The HTML (" < Span> I'm HTML code. / span>" );

JS:


var dobj=document.getElementById("div");
dobj.innerHTML = "<span> I am a HTML code </span>";

Method 2:

Use it when you find that data read from the database doesn't work either way


$("#div").html( " @Html.Raw( I'm in the database HTML code ) " );

Related articles: