私はjqueryに次のコードを持っています:
var qtype ="<select id='qtype'><option>qt1 </option><option>qt2</option></select>";
var abc ="<select id='t1'><option>Simple 1</option><option>Simple 2</option></select>";
var xyz ="<select id='t2'><option>Hard</option></select>";
var pqr ="<select id='t3'><option>Diff</option></select>";
$("#qttype").html(qtype);
var qtype=$("qttype");
if(qtype== "qt1"){
$("#t1").change(function(){
$("#abc").change(function(){
$("#divid").html(abc+xyz);
$("#divid").html(abc+xyz+pqr);
}); }
ただし、要素が正しく追加されません。つまり、「simple 1」を変更すると、「xyz」が付いた2番目のコンボボックスが表示されますが、もう一度クリックすると、二重に追加された要素が表示され、コンボボックスの値を変更したときに1回だけ表示します。