일부 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!');
}
});
코드뿐만 아니라 ID를 복제하고 그건 것 같습니다 아니, 아니. – j08691
글쎄, ID가있는 컨테이너 내부의 html을 가져 와서 실제 마크 업에서이를 반복하지 않습니다. 적어도 나는 그렇게 생각하지 않는다. .. 그러나 나는 두 번 점검 할 것이다. 감사. – TurboSupra