Jop*_*c67 3 javascript jquery google-chrome-extension
我试图用HTML查找HTML中的对象.
function getHats() {
$.get('http://www.roblox.com/User.aspx?ID=1',
function parse(data) {
var id1 = $(data).find('#ctl00_cphRoblox_rbxUserAssetsPane_UserAssetsDataList_ctl09_AssetThumbnailHyperLink');
hatname1 = id1.attr('title');
hatlink1 = "http://www.roblox.com" + id1.attr('href');
hatpic1 = id1.find('img').attr('src');
var lim1 = id1.parent('.AssetThumbnail').find('div');
if(!lim1) {
hatlim1 = true;
alert("Null")
}else{
hatlim1 = false;
};
}
);
};
Run Code Online (Sandbox Code Playgroud)
它总是弹出警报.
使用长度 - 但你不必明确它:
if (lim1.length) {
// lim1 has a length! And it's not 0!
} else {
// arg, lim1 has a length of 0
}
Run Code Online (Sandbox Code Playgroud)
等价地,否定运算符!将正常工作.
if (!lim1.length) {
// arg!
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1193 次 |
| 最近记录: |