jQuery Qtip继承

jQuery Qtip继承,jquery,qtip,Jquery,Qtip,我使用jQuery Qtip插件使用以下代码创建了一些工具提示: $('*[title]').each(function() { //if ($(this).attr('title') != "") { $(this).qtip({ content: $(this).attr('title'), position: { target: 'mouse',

我使用jQuery Qtip插件使用以下代码创建了一些工具提示:

$('*[title]').each(function() {
        //if ($(this).attr('title') != "") {
        $(this).qtip({
            content: $(this).attr('title'),
            position: {
                target: 'mouse',
                adjust: {
                    screen: true,
                    x: 5,
                    y: 15
                },
                corner: {
                    target: 'rightMiddle',
                    tooltip: 'leftMiddle'
                }
            },
            style: {
                fontSize: 11,
                padding: '2px 6px',
                textAlign: 'left',
                lineHeight: 1.5,
                fontWeight: 'bold',
                color: '#444',
                border: {
                    width: 1,
                    radius: 2
                },
                name: 'cream'
            }
        })
           .attr('title', '');
        // }
    });


    $('span.help').each(function () {
        $(this).qtip({
            /*content: {
            text: $(this).html()
            },*/
            content: $(this).attr('title'),
            position: {
                adjust: {
                    screen: false,
                    x: 0,
                    y: 0
                },
                corner: {
                    target: 'topRight',
                    tooltip: 'bottomRight'
                }
            },
            show: 'mouseover',
            hide: 'mouseout',
            style: {
                title: { 'font-size': 11, padding: '6px 6px', lineHeight: 1.5 },
                fontSize: 11,
                padding: '6px 6px',
                textAlign: 'left',
                lineHeight: 1.5,
                fontWeight: '600',
                border: {
                    width: 3,
                    radius: 3
                },
                tip: 'bottomRight',
                name: 'cream'
            }
        })
   .attr('title', '');
    });
基本上所有有标题的元素都有一个工具提示,但是我希望
help
类的元素有一个特殊的工具提示。发生的事情是,我得到了两个帮助元素的工具提示。是否可以用第二个完全覆盖第一个

也许使用某种if语句首先检查它是否不是帮助类,如果不是,则执行第一个函数,如果是,则执行第二个函数


谢谢

编辑:

var title = $(this).attr('title'),
    help = $(this).attr('class'),
    isHelp = undefined;

if(help !== undefined){
    var isHelp = help.search('help');
}


if(title !== undefined){


    if((title.length !== 0)&&((isHelp == -1)||(isHelp == undefined))){

        alert('do title tiptool function');

    }

}

示例:

您可以有一个选择器,如
$(“[title],.help”)
,用于选择要提供工具提示的所有元素。然后,在每个匿名函数中,使用
$(this).hasClass(“help”)
确定要为该元素提供的工具提示。

您是否尝试过在第一次选择中添加:not()子句以排除帮助范围

 $('*[title]:not(span.help)').each(function() {

在修正了课堂问题后,我更新了我的答案。