How can I use a carriage return in a HTML tooltip?

前端 未结 27 1557
说谎
说谎 2020-11-22 11:59

I\'m currently adding verbose tooltips to our site, and I\'d like (without having to resort to a whizz-bang jQuery plugin, I know there are many!) to use carriage returns to

27条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-22 12:35

    We had a requirement where we needed to test all of these, here is what I wish to share

    document.getElementById("tooltip").setAttribute("title", "Tool\x0ATip\x0AOn\x0ANew\x0ALine")

    Tooltip with

      new 
      line
    Works in all browsers


    Tooltip with 
 Not works Firefox browsers


    Tooltip with 
 Works in some browsers


    Tooltip with 
 May work in some browsers


    Tooltip with document.getElementById("tooltip").setAttribute("title", "Tool\x0ATip\x0AOn\x0ANew\x0ALine") May work in some browsers


    Tooltip with Unordered list tooltip


    Tooltip with \n May not work in modern browsers


    Tooltip with \t May not work in modern browsers


    Tooltip with 
 Works in most browsers


    Fiddle

提交回复
热议问题