我有脚本在选择框中显示下拉菜单。目前我正在使用的脚本是将jquery的每个函数转换为纯javascript
jQuery.each(dslr, function(index, dslrgp) {
var aslrp= dslrgp.aslrp;
jQuery.each(aslrp, function(index2, pslrp) {
var found = 0;
jQuery.each(dropdown, function(index3, dditem) {
if (dditem.countryname == pslrp.countryname)
{
foundit = 1;
}
});
if (foundit == 0)
dropdown.push(pslrp);
});
});
我该如何将其转换为纯javascript。因为如果我使用这个
dslr.forEach(function(index, dslrgp) {
var aslrp= dslrgp.aslrp;
aslrp.forEach(function(index2, pslrp) {
var found = 0;
dropdown.forEach(function(index3, dditem) {
if (dditem.countryname == pslrp.countryname)
{
foundit = 1;
}
});
if (foundit == 0)
dropdown.push(pslrp);
});
});
它不起作用。
“它不工作” - 定义 “不工作”。给出一个明确的问题陈述。你得到的行为与你期望的行为有什么不同? – Quentin
“将jquery的每个函数转换为纯javascript” - jQuery **是纯JavaScript代码。有完全有效的理由想要移除对jQuery的依赖,但不要将jQuery误认为是JavaScript以外的任何东西。 – Quentin
我编辑了我的问题。 –