2

I am having a problem with adding tooltip to :before element. For example my input become error and inside <div class="form-group has-error"> is :before element that has icon. And I want to add with jQuery tooltip to this before element.

This is my code:

$('body').tooltip({
    selector: '[data-input].has-error:before',
    animation: true,
    container: 'body',
    placement: 'bottom',
    title: 'error message'
});

or this:

$('[data-input].has-error:before').on('hover', function () {
    $(this).tooltip({
        animation: true,
        container: 'body',
        placement: 'bottom',
        title: 'error message'
    });
});

Any ideas?

cfnerd
  • 3,658
  • 12
  • 32
  • 44
Nienormalny_
  • 460
  • 3
  • 14
  • 1
    Possible duplicate of [Selecting and manipulating CSS pseudo-elements such as ::before and ::after using jQuery](https://stackoverflow.com/questions/5041494/selecting-and-manipulating-css-pseudo-elements-such-as-before-and-after-usin) – Daniel Maiochi Oct 11 '17 at 08:21
  • It may be a solution, try to insert an other dom element, for example div in "[data-input]. has-error: before" and inject tooltip code in! –  Oct 11 '17 at 08:26

0 Answers0