CSS data attribute new line character & pseudo-element content value

前端 未结 4 1868
臣服心动
臣服心动 2020-11-27 05:36

Is it possible to have a new line in a data attribute ?

I am trying to do something like this:

CSS:

[         


        
4条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-27 05:49

    Okay, Here is one easy way to do this. you should write it as

    data-foo='First line 
    Second Line'

    and instead of using .text(), you can use .html(). when you use .html() then it will take as line break and this should solve your problem.

提交回复
热议问题