【发布时间】:2018-05-22 21:47:04
【问题描述】:
假设我有一个函数,里面有一个对象
function MyFunction(){
var options = {
placeholder: $('#select option[value="-1"]'),
first: $('#select option[value="-1"]').next()
};
}
你看,jQuery 对象$('#select option[value="-1"]') 在placeholder 和first 项目中都有重复。这可行,但 PHPStorm 警告我有关重复的 jQuery 选择器
有没有办法可以引用first 项目中的placeholder 值?排序如下:
placeholder: $('#select option[value="-1"]'),
first: this.placeholder.next()
(当然提供的示例不起作用)
【问题讨论】: