gpt4 book ai didi

javascript - jquery/Javascript 语法

转载 作者:搜寻专家 更新时间:2023-11-01 04:52:44 24 4
gpt4 key购买 nike

我想弄清楚下面的语法是做什么的。它是来自 Bootstraps 弹出窗口的代码。

//title is a string
$tip.find('.popover-title')[ $.type(title) == 'object' ? 'append' : 'html' ](title)
^ ^
What does this symbol mean? Whats happening here?

最佳答案

让我们分解一下:

$tip.find('.popover-title')[ $.type(title) == 'object' ? 'append' : 'html' ](title)

可以分解为:

var found = $tip.find('.popover-title');
found[$.type(title) == 'object' ? 'append' : 'html'](title);

还有更多:

var found = $tip.find('.popover-title');

if ($.type(title) == 'object') {
found['append'](title);
} else {
found['html'](title);
}

多一点:

var found = $tip.find('.popover-title');

if ($.type(title) == 'object') {
found.append(title);
} else {
found.html(title);
}

关于javascript - jquery/Javascript 语法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9915077/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com