2

I am populating a select form menu list based on another menu selection (in wordpress) with jquery code below. It works fine in all browsers excepet ie9/8. Any advice appreciated.

$jmake = $j("select[name='make']");
$jmodel = $j("select[name='model']");

$jmake.change(function (){
if($j(this).val() == "ALFA ROMEO") {
    $j("select[name='model'] option").remove();
    $j("<option>GT</option>").appendTo($jmodel);
    $j("<option>BRERA</option>").appendTo($jmodel);
    }

..hopefully that's clear. Thanks.

4

2 回答 2

0

I think there is syntax error in your script:

$jmake.change(function (){
if($j(this).val() == "ALFA ROMEO") {
    $j("select[name='model'] option").remove();
    $j("<option>GT</option>").appendTo($jmodel);
    $j("<option>BRERA</option>").appendTo($jmodel);
    }
);
于 2012-10-12T09:19:48.300 回答
0

试试下面。

$jmodel.append('<option></option>').val(val).html(text)
于 2012-10-12T09:56:25.267 回答