我正在编写一段JavaScript代码,以便在Nike.com上自动选择鞋码。当我运行log to debug时,我得到了正确的下拉容器。我无法选择尺寸。我不能硬编码大小,因为我希望这适用于所有鞋码。
function sizeSelect(){
var sizeMenu = document.getElementsByClassName("exp-pdp-size-container exp-pdp-dropdown-container nsg-form--drop-down");
var size = document.getElementsByName("skuAndSize")[0];
for(var i = 0; i < size.options.length; i++) {
console.log(size.options[i].index);
if(size.options[i].index == shoesize){
document.getElementsByName("skuAndSize")[0].options.selectedIndex = i; +
//gets correct options but can't seem to change the size option on webpage
break;
}
}