首先我想在我忘记之前给你链接。
http://www.roblox.com/User.aspx?ID=1
页面底部有多个选项卡。 (装备、帽子、面孔、包裹等)
function checkForHat() {
$.get (
'http://www.roblox.com/User.aspx?ID=1',
function parse(data) {
var hatid1 = $(data).find('#ctl00_cphRoblox_rbxUserAssetsPane_UserAssetsDataList_ctl00_AssetThumbnailHyperLink');
var hatidtitle1 = hatid1.attr('title');
var hatidhref1 = "http://www.roblox.com" + hatid1.attr('href');
var hatidpi1 = $(hatid1).find('img')
var hatidpic1 = hatidpi1.attr('src')
hatLink1 = hatidhref1;
hatTitle1 = hatidtitle1;
hatPic1 = hatidpic1;
var hatid2 = $(data).find('#ctl00_cphRoblox_rbxUserAssetsPane_UserAssetsDataList_ctl01_AssetThumbnailHyperLink');
var hatidtitle2 = hatid2.attr('title');
var hatidhref2 = "http://www.roblox.com" + hatid2.attr('href');
var hatidpi2 = $(hatid2).find('img')
var hatidpic2 = hatidpi2.attr('src')
hatLink2 = hatidhref2;
hatTitle2 = hatidtitle2;
hatPic2 = hatidpic2;
var hatid3 = $(data).find('#ctl00_cphRoblox_rbxUserAssetsPane_UserAssetsDataList_ctl02_AssetThumbnailHyperLink');
var hatidtitle3 = hatid3.attr('title');
var hatidhref3 = "http://www.roblox.com" + hatid3.attr('href');
var hatidpi3 = $(hatid3).find('img')
var hatidpic3 = hatidpi3.attr('src')
hatLink3 = hatidhref3;
hatTitle3 = hatidtitle3;
hatPic3 = hatidpic3;
if (hatLink3 != null && hatTitle3 != null && hatPic3 != null) {
checkIfNew3();
}
if (hatLink2 != null && hatTitle2 != null && hatPic2 != null) {
checkIfNew2();
}
if (hatLink1 != null && hatTitle1 != null && hatPic1 != null) {
checkIfNew1();
}
}
);
};
当然,有些变量已经在代码的前面调用过了。
现在我的问题是如何使用 JQuery 更改选项卡。就像我说的那样,标签位于底部。
这个答案开始变得至关重要,因为我有很多要求升级它所在的 chrome 扩展程序的请求。
谢谢。
最佳答案
似乎用于执行选项卡切换的 javascript 保存在 href 属性中。您可以对该方法执行 eval。
//this will click the shirts tab
eval($('#ctl00_cphRoblox_rbxUserAssetsPane_AssetCategoryRepeater_ctl05_AssetCategorySelector').attr('href'))
如果你想要更强大的东西,那么:
$shirtElem = $('#assetsMenu a').filter( function() {
if ($(this).html() == 'Shirts') return true;
});
eval($shirtElem.attr('href'));
我都不喜欢,但这看起来像是自动生成的 visual studio 代码,这意味着它会很难看并且很难使用 =)。我还假设您对源没有任何控制权,否则这会简单得多。
关于javascript - 有没有一种在 JQuery 中切换选项卡的方法?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8951118/