I am trying to use javascript to change a value of a select box on a ToysRUs address page. The project is an extension that fills out an address form automatically.
The item id is billingAddress.address.stateSelect
document.getElementById("billingAddress.address.stateSelect") // returns the element.
$("#billingAddress.address.stateSelect") // returns null.
I wanted to use $("#billingAddress.address.stateSelect").val("CA")
to change the selection, but I cannot because it is null.
The page is using jQuery
(typeof jQuery != 'undefined') // is true
I still get null after escaping the periods with backslashes.
s=document.getElementById("billingAddress.address.stateSelect").id;
console.log(s);
s= "#"+s.replace( /(:|\.|[|])/g, "\\$1" );
//also tried \\\\ backslashes and \\\ backslashes
console.log(s); //gives billingAddress\\.address\\.stateSelect
console.log($(s)); //is still null