The database stores HTML with styles attached. How to modify existing styles and database styles on the Interface
When I encountered such a problem at work, the database stores HTML code and also has a style. I want to modify the style he has written on the interface, for example, to change the font of this field to, the corresponding field content in the database is as follows:
On the interface, you can directly put this HTML section on the interface. Here, ko is Knockoutjs, And the html in data-bind: html: JobDesc is used: jobDesc effect and @ Html. the Raw () effect is the same, even if the HTML code in the database is directly inserted into the interface. Code such
To change the style inside: it is very easy to overwrite the style inside. This is not the problem. The HTML inserted in is actually
<Div class = "col-xs-9 as" data-bind = "html: JobDesc">
</Div>
To modify the style of the child element.
$ ("Div [class = 'col-xs-9 as ']"). find ("*" ).css ("font-family", "Microsoft YaHei ");
The find ("*") method is used to return all descendants of the selected tag.
This is a situation,
Another case is that there is no HTML Tag and only text in the database. In this case, you need to add a sentence.
$ ("Div [class = 'col-xs-9 as ']" ).css ("font-family", "Microsoft YaHei ");
To sum up, add the following code in js:
$ (Function (){
$ ("Div [class = 'col-xs-9 as ']" ).css ("font-family", "Microsoft YaHei ");
$ ("Div [class = 'col-xs-9 as ']"). find ("*" ).css ("font-family", "Microsoft YaHei ");
});