0

jquery ドロップダウン メニューを使用しています。ほぼ完了しましたが、何らかの理由で onChange を機能させることができません。

<select id="cd-dropdown" class="cd-select" ONCHANGE="location = this.options[this.selectedIndex].value;" >
    <option value="-1" selected>Selecione uma categoria</option>
    <option value="1" class="icon-google-plus">Massa Muscular</option>
    <option value="2" class="icon-facebook">Resistência</option>
    <option value="http://www.google.com" class="icon-twitter" >Vitaminas</option>
    <option value="4" class="icon-github">Emagrecimento</option>
</select>
4

3 に答える 3

1

使用location.href:

<select id="cd-dropdown" class="cd-select"
        ONCHANGE="location.href = this.options[this.selectedIndex].value;" >
------------------^

説明

キーワードlocationはオブジェクトです。オブジェクトのhrefプロパティはlocationURL を示します。

完全なコード:

<select id="cd-dropdown" class="cd-select" ONCHANGE="location.href = this.options[this.selectedIndex].value;" >
    <option value="-1" selected>Selecione uma categoria</option>
    <option value="1" class="icon-google-plus">Massa Muscular</option>
    <option value="2" class="icon-facebook">Resistência</option>
    <option value="http://www.google.com" class="icon-twitter" >Vitaminas</option>
    <option value="4" class="icon-github">Emagrecimento</option>
</select>
于 2013-10-30T17:26:16.520 に答える