How to enable Bootstrap tooltip on disabled button?

后端 未结 18 2448
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-28 23:18

I need to display a tooltip on a disabled button and remove it on an enabled button. Currently, it works in reverse.

What is the best way to invert this behaviour?

18条回答
  •  攒了一身酷
    2020-11-29 00:01

    You can wrap the disabled button and put the tooltip on the wrapper:

    If the wrapper has display:inline then the tooltip doesn't seem to work. Using display:block and display:inline-block seem to work fine. It also appears to work fine with a floated wrapper.

    UPDATE Here's an updated JSFiddle that works with the latest Bootstrap (3.3.6). Thanks to @JohnLehmann for suggesting pointer-events: none; for the disabled button.

    http://jsfiddle.net/cSSUA/209/

提交回复
热议问题