我有两个选择控件,我想用完全相同的选项填充。
我开始使用以下代码(不起作用):
var result = // raw <option></option> html from ajax call
$("#selImbServiceType").html(result);
$("#selRemitImbServiceType").html(result);
如果我注释掉上面的任何一个陈述,那么剩下的一个就可以了,但是当它们都被取消注释时,只有第一个有效。
然后我将代码更改为以下代码(这可以按预期工作):
var result = // raw <option></option> html from ajax call
$("#selImbServiceType,#selRemitImbServiceType").html(result);
第二个版本填充了两个控件。
我正在使用jQuery 1.4.4和Firefox 5.0.1
知道为什么第一个版本不起作用?
结果变量HTML
以下是结果变量的内容:
<option value="27b3dc65-d60c-46e3-8d9c-bdffad8bc25f">Return To Sender</option>
<option value="bcf435c9-d197-4a54-8d90-f4507c2ac505">Shred And Return Electronically</option>
周边HTML
<div style="overflow:auto;width:100%;">
<div style="float:left;width:50%">
<span class="dialogControlLabel">Client</span>
<br />
<select id="listClients" onchange="clientSelectionChanged()"></select>
<span id="spanClientsLoading" style="display:none;"><img src="/Theme/Images/ajax-loader-fb.gif" alt="loading" width="16" height="11" /></span>
<br />
<br />
<span class="dialogControlLabel">IMB Service Type</span>
<br />
<select id="selImbServiceType" name="imbServiceType"></select>
<br />
<br />
<span class="dialogControlLabel">Stream Name</span>
<br />
<input id="txtStreamName" type="text" maxlength="128" name="streamName" />
<br />
<br />
<span class="dialogControlLabel">Processor Module</span>
<br />
<input id="txtProcessorModule" type="text" maxlength="256" name="processorModule"/>
<br />
<br />
<span class="dialogControlLabel">Advanced Location Logic Enabled</span>
<br />
<select id="selAdvancedLocationLogicEnabled" name="advancedLocationLogicEnabled">
<option value="1">Yes</option>
<option value="0">No</option>
</select>
<br />
<br />
<span class="dialogControlLabel">Force Mail Enabled</span>
<br />
<select id="selForceMailEnabled" name="forceMailEnabled">
<option value="1">Yes</option>
<option value="0">No</option>
</select>
</div>
<div style="float:right;width:50%">
<span class="dialogControlLabel">File Stream Configuration</span>
<br />
<select id="selFileStreamConfig"></select>
<br />
<br />
<span class="dialogControlLabel">Remit IMB Service Type</span>
<br />
<select id="selRemitImbServiceType" name="remitImbServiceType"></select>
<br />
<br />
<span class="dialogControlLabel">NCOA Enabled</span>
<br />
<select id="selNcoaEnabled" name="ncoaEnabled">
<option value="1">Yes</option>
<option value="0">No</option>
</select>
<br />
<br />
<span class="dialogControlLabel">Skip Logic Enabled</span>
<br />
<select id="selSkipLogicEnabled" name="skipLogicEnabled">
<option value="1">Yes</option>
<option value="0">No</option>
</select>
<br />
<br />
<span class="dialogControlLabel">Active</span>
<br />
<select id="selActive" name="active">
<option value="1">Yes</option>
<option value="0">No</option>
</select>
</div>
</div>