「変数の . 演算子の後に名前がありません」というこの JavaScript エラーを修正する必要があります。これは、私が作業しようとしている現在のコードです。
<!DOCTYPE html>
<html>
<body onload="myFunction()">
<select>
<option>1</option>
</select>
<br/>
<select>
<option>1</option>
</select>
<script>
function myFunction()
{
if(typeof document.body.ontouchstart == "undefined"){actionIn = "onmouseover"; actionOut = "onmouseout"}
else{actionIn = "ontouchstart"; actionOut = "ontouchend";}
var elem = document.getElementsByTagName("SELECT");
for (var i = 0;i < elem.length; i++){
elem[i].[actionIn] = function(){this.style.background='red';}
elem[i].[actionOut] = function(){this.style.background='';}
}
}
</script>
</body>
</html>