简体   繁体   中英

how to write html in inline JavaScript, with CSS inline style

I need to write some html in inline JavaScript, with CSS inline style, how to do so

something like this <p><span style="color: #ff0000;">test</span></p>

<button class="pop-up display-screen" id="targetElement111"
    (click)="targetElement='targetElement111';model.title='';
    model.content='/*need to write some htmlhere*/';
    customTarget.open()">Open myModal
</button>

thanks in advance

You can include HTML in the string, and escape the quotes

 <button class="pop-up display-screen" id="targetElement111"
    (click)="targetElement='targetElement111';model.title='';model.content='<p><span style=\"color: #ff0000;\">test</span></p>';customTarget.open()">Open
    myModal</button>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM