Riv*_*ver 4 javascript jquery popover twitter-bootstrap
我想弄清楚下面的语法是做什么的.这是来自Bootstraps popover的代码.
//title is a string
$tip.find('.popover-title')[ $.type(title) == 'object' ? 'append' : 'html' ](title)
^ ^
What does this symbol mean? Whats happening here?
Run Code Online (Sandbox Code Playgroud)
我们分手吧:
$tip.find('.popover-title')[ $.type(title) == 'object' ? 'append' : 'html' ](title)
Run Code Online (Sandbox Code Playgroud)
它可以分解为:
var found = $tip.find('.popover-title');
found[$.type(title) == 'object' ? 'append' : 'html'](title);
Run Code Online (Sandbox Code Playgroud)
和更多:
var found = $tip.find('.popover-title');
if ($.type(title) == 'object') {
found['append'](title);
} else {
found['html'](title);
}
Run Code Online (Sandbox Code Playgroud)
再来一点:
var found = $tip.find('.popover-title');
if ($.type(title) == 'object') {
found.append(title);
} else {
found.html(title);
}
Run Code Online (Sandbox Code Playgroud)
它基本上是这样说的:
if(typeof title == 'object') {
$tip.find('.popover-title').append(title);
}
else {
$tip.find('.popover-title').html(title);
}
Run Code Online (Sandbox Code Playgroud)
该[...]
符号允许你动态地选择从功能$tip.find('.popover-title')
对象.
归档时间: |
|
查看次数: |
114 次 |
最近记录: |