Bootstrap tooltip data-toggle

前端 未结 3 2521
伪装坚强ぢ
伪装坚强ぢ 2021-02-20 01:10

In the Bootstrap documentation page, the tooltip has a signature of:

hover over me
         


        
3条回答
  •  栀梦
    栀梦 (楼主)
    2021-02-20 01:51

    They've chosen to use data-toggle as an indicator in their JavaScript for when something is a tooltip. When the tooltips JS file sees the data-toggle="tooltip" attribute, it knows to kick in and run.

    A more common approach might be to use a class (hover over me), but they've gone data-* attribute instead. Does the same thing, works, and philisophically, data-* attributes were designed for JavaScript manipulation, so I suppose it's good to keep it class free.

提交回复
热议问题