The database stores HTML with styles attached. How to modify existing styles and database styles on the Interface

Source: Internet
Author: User

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 ");
});

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.