我有一些HTML我正在使用CMS的編程我沒寫,它正在輸出一些HTML無線電選項,並重復它們。不幸的是,我無法控制這個編程的輸出,所以我正在嘗試一種替代路線,只試圖讓一個HTML實例出現。這裏有一個例子:如何過濾掉重複的HTML與jQuery
<label class="fc_radio" for="shipping_service_101"><input type="radio" name="shipping_service" id="shipping_service_101" value="101|45" class="fc_radio fc_required"><span class="fc_shipping_carrier">USPS International Shipping Rate (tracking included)</span> <span class="fc_shipping_cost"><span class="fc_currency_symbol">$</span>45</span> </label>
<label class="fc_radio" for="shipping_service_101"><input type="radio" name="shipping_service" id="shipping_service_101" value="101|45" class="fc_radio fc_required"><span class="fc_shipping_carrier">USPS International Shipping Rate (tracking included)</span> <span class="fc_shipping_cost"><span class="fc_currency_symbol">$</span>45</span> </label>
正如你所看到的,它是相同的代碼。無論如何,jQuery基本上過濾掉了正在輸出的額外的HTML,並保留了HTML中的1個實例?他們是這個ID和Class一個div內:
<div id="fc_shipping_methods_inner" class="fc_shipping_methods_inner">
REPEATING HTML HERE
</div>
您應該解決的問題或有您使用修復它的解決方案的開發。這樣的事情是一個錯誤,你不應該用JS包紮它。 – prodigitalson
同意。必須破解,直到找到解決辦法。絕對不是一個長期的解決方案,但現在仍然是一種解決方案。 – flinx777