「製品を追加」をクリックするたびに、いくつかのhtmlを取得して繰り返すjQueryスクリプトがあります。これで一見うまく動作するようになりましたが、複数の製品 (同じ製品) を追加できることに気付きました。したがって、ラジオボタンが干渉します。一意のラジオ名属性が必要です。これを行うことでどこから始めればよいかさえわかりません。カウンターを作成して現在の名前に追加できると思います...助けてくれてありがとう。
html の例を次に示します。
<div id="product-container" class="product-container" style="display:none">
<div class="product-wrapper white-rounded">
<div id="product-name" style="display:none"></div>
<h4>Example Product 1</h4>
<span class="align-right">
<input name="select2" type="radio"><strong style="margin-right:20px">Option 1</strong>
<input name="select2" type="radio"><strong>Option 2</strong>
</span>
<div class="remove float-right">
<a href="#"><div class="img-remove"></div>Remove</a>
</div>
<div class="clear"></div>
</div>
</div>
そして、コードを取得してアンカー ポイントで吐き出す jQuery を次に示します。
$('.add-product').click(function() {
if (Products < 4 || (Products == 4 && Products2 == 1)) {
//Store html contents in Variable
var thisProduct = $('#product-container').html()
//Add account html to account center anchor point
$('.add-product').before(thisProduct)
$('#product-name').text(productName)
//Add one more Product Count
Products++
//Add Product Count value to hidden Input Field, then manually trigger the change event.
$('.product-count').val(Products).change()
//Scroll to top of page after account is added
$('html, body').animate({scrollTop:0}, 'slow');
}
else {
alert('HALP!');
}
});