0
私がしようとしているのは、breed_selectorドロップダウンメニューを開き、breed1を選択してからクリックし、次の品種に移動してクリックして続行することです。この3回、残念ながら、それは犬とクリックの最初の品種を選択するだけで、3つすべてを選択することはありません。Javascriptもう一度クリックして実行してください
おかげ
(function() {
var x = document.getElementById("breed_selector).options;
for(var i=0;i<x.length;i++){
if(x[i].text=="Labrador"){
x[i].selected=true;
document.getElementsByClassName("shop")[0].click();
break;
}
}
var x = document.getElementById("breed_selector").options;
for(var i=0;i<x.length;i++){
if(x[i].text=="poodle"){
x[i].selected=true;
document.getElementsByClassName("shop")[0].click();
})();
現時点では、それだけで何もしていませんが、
私は
var = document.getElementById("breed_selector").options;
for(var i=0;i<x.length;i++){
if(x[i].text=="poodle", "Labrador", "pug"){
x[i].selected=true;
document.getElementsByClassName("shop")[0].click();
break;
を試してみましたが、上記のいずれかに動作しない、任意の入力を希望偉大な、ありがとう:)
まだ動作しない更新コード
(function() {
var x = document.getElementById("breed_selector").options;
for(var i=0;i<x.length;i++){
var text = x[i].text;
if(x[i].text === "Labrador" && text === "Pug"){
x[i].selected=true;
document.getElementsByClassName("shop")[0].click();
break;
}
}
})();
:
その値に基づいてのみ、特定のオプションを選択するために、あなたのような何かを試みることができます'click'イベントはバインドされていますか? –
ちょっと、私は正直言ってあなたが何をしているのかということには少しも手がかりがありません。私は最近JSに入ったばかりです。最初のものの品種だけを見つけて、それらのすべてではなくクリックしているだけです。 – TedLIndsay
更新されたコードでは、なぜ同じ変数を2つの異なる値と比較していますか?** && **条件でも同じですか?それは常に 'false'を与えます。 – aquaman