jQuery Tooltip: вставка HTML-кода со ссылками - PullRequest
0 голосов
/ 13 февраля 2019

У меня в подсказках WordPress работают подсказки, подобные этой (http://vps46331.inmotionhosting.com/~hellod8/10-fun-things-to-do-with-kids-this-weekend-2-15-19-2-17-19/) внизу страницы в ссылке «Поделиться»). Однако я также хочу включить HTML-код в код, и вот где яЯ вычеркнул.

Я нашел эту скрипку: http://jsfiddle.net/AK7pv/111/

Но добавление этого к названию моей ссылки все портит, и он просто выплевывает HTML во всплывающей подсказке:

<p>Share <button id="trigger" class="trigger" data-html="true" data-tooltip-id="1" title="<p><a href='#' title='Email'><i class='fas fa-envelope'></i> Email</a><br><a href='#' title='Copy Link'><i class='fas fa-link'></i> Copy Link</a></p>"><i class="fas fa-share"></i></button></p>

Это текущий Javascript:

jQuery(function () {
    //show
    jQuery(document).on('click', '.trigger', function () {
        jQuery(this).addClass("on");
        jQuery(this).tooltip({
            items: '.trigger.on',
                position: {
                    my: "right+10 center",
                    at: "left center",
                    collision: "flip"
            }
        });
        jQuery(this).trigger('mouseenter');
    });
    //hide
    jQuery(document).on('click', '.trigger.on', function () {
        jQuery(this).tooltip('close');
        jQuery(this).removeClass("on");
    });
    //prevent mouseout and other related events from firing their handlers
    jQuery(".trigger").on('mouseout', function (e) {
        e.stopImmediatePropagation();
    });
});

1 Ответ

0 голосов
/ 13 февраля 2019

Прежде всего ваш открывающий тег <button> не закрыт.Также вам может понадобиться data-html=true в разметке кнопки.

...