【问题标题】:dynamic tooltip for bootstrap select引导选择的动态工具提示
【发布时间】:2019-02-12 14:39:49
【问题描述】:

当我将鼠标移到项目工具提示文本上时,我需要将动态工具提示添加到引导选择下拉列表中,该文本应显示其值。 但在我的示例中仅显示静态文本或同时显示所有项目值!(在图片中) [https://cdn1.imggmi.com/uploads/2018/9/7/21093ba294817db8cb4cf968e467fe64-full.png] 如何将每个项目值放入项目工具提示?

谢谢

// in this I try to add each span text to each li element???
    var tooltipMap = {};
    $('#id').data('selectpicker').$lis.each(function () {
    var li = $(this);
    var elementtext = li.find('span.text').text();
    var tooltipString = tooltipMap[elementtext];
    if (tooltipString){
        li.tooltip({ trigger: 'hover', placement: 'right', title: tooltipString }); }

//show only static text inside tooltip for all loaded items
    $('#id').data('selectpicker').$lis.attr('title', 'static text').tooltip();}); 

【问题讨论】:

  • 我自己找到了解决方案,谢谢

标签: twitter-bootstrap jquery-selectors bootstrap-selectpicker


【解决方案1】:

工作版

 $("#id").each(function (i) {

                if ( i > 0 ) {
                    var test= "title is : " + $(this).text();

                    $(this).attr("title", sube).tooltip();
                   //alert(test);
                }

        });

处理静态文本

$('#id').on('shown.bs.select', function () {
$($(this).data('selectpicker').current.elements).attr('title', sube).tooltip();
 });

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多