gpt4 book ai didi

jquery html() 替换整个字段集

转载 作者:行者123 更新时间:2023-12-01 08:11:43 24 4
gpt4 key购买 nike

我正在尝试使用 jquery 更新选择框,但不只是替换 <div>包含选择框。 html()正在替换整个 <fieldset> 。我已经尝试了所有方法,但看不出我哪里出错了。

我的jquery是:

$('div.companyselect', $(parent.document)).html(data.success);

我的 HTML 是:

<fieldset>
<legend>Company Information</legend>
<div class="column-left">
<label>Manufacturer Name:</label>
<div class="companyselect"><?php echo $select ?><div>&nbsp;

<a href="../forms/modal_company.php" class="various fancybox.ajax" style="font-size:12px;">Add a Company</a>

</div>
<div class="clear"></div>
</fieldset>
<fieldset>
<legend>Vendor Information</legend>
<div class="column-left">
<label>First Name</label>
<input name="name" class="text-input medium4-input required" type="text" id="name" value="">
</div>
<div class="column-right medium_margin">
<label>Last Name:</label>
<input name="last" class="text-input medium4-input required" type="text" id="last" value="">
</div>
<div class="clear"></div>
<div>
<label>Address:</label>
<input name="address" class="text-input medium2-input required" type="text" id="address" value="">
</div>
<div class="clear"></div>
<div class="column-left" style="width:52%">
<label>City:</label>
<input name="city" class="text-input medium3-input required" type="text" id="city" value="" >
</div>
<div class="column-left" style="width:15%">
<label>State:</label>
<input name="state" class="text-input small-input required" type="text" id="state" value="">
</div>
<div class="column-left" style="width:30%">
<label>Zipcode:</label>
<input name="zipcode" class="text-input medium5-input required" type="text" id="zipcode" value="" >
</div>
<div class="clear"></div>
<div class="column-left medium_margin">
<label>Phone:</label>
<input name="tel" class="text-input medium-input required" type="text" id="tel" value="">
</div>
<div class="column-right medium_margin">
<label>(optional) Fax:</label>
<input name="fax" class="text-input medium-input" type="text" id="fax" value="">
</div>
<div class="clear"></div>
</fieldset>

有人可以帮助我理解为什么整个第一个被替换而不仅仅是 with class="companyselect"吗?

最佳答案

很可能是由于 HTML 损坏:

<div class="companyselect"><?php echo $select ?><div>&nbsp;

应该是:

<div class="companyselect"><?php echo $select ?></div>&nbsp;

关于jquery html() 替换整个字段集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13196053/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com