select의 1 옵션에 따라 전체 옵션 목록을 변경해야하는 userscript가 있습니다. 오페라에서이 스크립트는 정상적으로 작동하지만 크롬에서는 작동하지 않습니다 (예, jQuery를 사용할 수 있음).프로그래밍 방식으로 <option>을 선택하면 Chrome에서는 작동하지 않지만 Opera에서는 작동합니다.
HTML :
<select id="autoConfig-gametype" style="width: 100%;">
<option value="1" selected="">1. [RECOMMENDED] All latest Game-settings, Paladin, archers, simple tech smithy</option>
<option value="2">2. No paladin, archers, simple tech system [TWMASTERS Settings]</option>
<option value="3">3. No paladin, no archers. Packages, 3 lvl tech-system. [CLASSIC]</option>
</select>
<select name="game::tech">
<option value="0">0: 10 level</option>
<option value="1">1: 3 level (up to 15)</option>
<option value="2" selected="selected">2: Simple</option>
</select>
가 jQuery를 통해 내가 attr
및 prop
을 사용했지만, 모두 크롬에서 어떤 결과가 없습니다. 조작해야 할 선택 영역은 변경되지 않습니다.
jQuery를 : 만 크롬을 사용하는 사람이 스크립트를 제작하고 있기 때문에
$("#autoConfig-gametype").change(function()
{
var value = $(this).val();
switch(value)
{
case "1":
// Game > Tech
$("[name='game::tech'] option").removeProp("selected");
$("[name='game::tech'] option").removeAttr("selected");
$("[name='game::tech'] option:eq(0)").attr("selected",true);
$("[name='game::tech'] option:eq(0)").prop("selected",true);
break;
case "2":
// Game > Tech
$("[name='game::tech'] option").removeProp("selected");
$("[name='game::tech'] option").removeAttr("selected");
$("[name='game::tech'] option:eq(1)").attr("selected",true);
$("[name='game::tech'] option:eq(1)").prop("selected",true);
break;
case "3":
// Game > Tech
$("[name='game::tech'] option").removeProp("selected");
$("[name='game::tech'] option").removeAttr("selected");
$("[name='game::tech'] option:eq(2)").attr("selected",true);
$("[name='game::tech'] option:eq(2)").prop("selected",true);
break;
}
});
나는 가지, 바로 지금 여기 붙어있다.
시각적으로. 시각적으로 변경되지만 DOM (Chrome에 따라)에서는 기본 옵션이 여전히 선택되었다고 말합니다. 액션이있는 양식이 어떻게 이것을 사용할 지 모르겠습니다. –
Chrome DOM은 어떤 이유로 든 콘솔에서 변경되지 않지만 [선택한 값을 경고하면 올바른 값을 표시합니다] (http://jsfiddle.net/6bxew/1/). – Ohgodwhy
좋아, 그럼이 스크립트는 지금 제대로 작동합니다 :) 고마워요! –