HTML:
<div class="busket ">
<button id="buybtn" class="btn btn-success" href="#OrderModal" data-toggle="modal" name="id" data-id=",1,2" data-quantity=",1,1"><span class="icon16 icomoon-icon-checkmark-2"></span>Buy</button>
<div class="form-row row-fluid" id="addeditem1"><div class="cpan12"><div class="span4"> <span class="ui-spinner ui-widget ui-widget-content ui-corner-all"><input class="spinner1 ui-spinner-input" id="addedq1" value="1" min="1" name="value" aria-valuemin="1" aria-valuenow="1" autocomplete="off" role="spinbutton"><a class="ui-spinner-button ui-spinner-up ui-corner-tr ui-button ui-widget ui-state-default ui-button-text-only" tabindex="-1" role="button" aria-disabled="false"><span class="ui-button-text"><span class="ui-icon ui-icon-triangle-1-n">▲</span></span></a><a class="ui-spinner-button ui-spinner-down ui-corner-br ui-button ui-widget ui-state-default ui-button-text-only" tabindex="-1" role="button" aria-disabled="false"><span class="ui-button-text"><span class="ui-icon ui-icon-triangle-1-s">▼</span></span></a></span></div></div><div class="span6"><img class="addedimg" src="/amrajegeachi18/productImages/small/1.png"></div><div class="span2"><span class="icon12 remove-item icomoon-icon-cancel" id="1"></span></div></div><div class="form-row row-fluid" id="addeditem2"><div class="cpan12"><div class="span4"> <span class="ui-spinner ui-widget ui-widget-content ui-corner-all"><input class="spinner1 ui-spinner-input" id="addedq2" value="1" min="1" name="value" aria-valuemin="1" aria-valuenow="1" autocomplete="off" role="spinbutton"><a class="ui-spinner-button ui-spinner-up ui-corner-tr ui-button ui-widget ui-state-default ui-button-text-only" tabindex="-1" role="button" aria-disabled="false"><span class="ui-button-text"><span class="ui-icon ui-icon-triangle-1-n">▲</span></span></a><a class="ui-spinner-button ui-spinner-down ui-corner-br ui-button ui-widget ui-state-default ui-button-text-only" tabindex="-1" role="button" aria-disabled="false"><span class="ui-button-text"><span class="ui-icon ui-icon-triangle-1-s">▼</span></span></a></span></div></div><div class="span6"><img class="addedimg" src="/amrajegeachi18/productImages/small/2.png"></div><div class="span2"><span class="icon12 remove-item icomoon-icon-cancel" id="2"></span></div></div></div>
Jquery的:
$('.busket>.spinner1').each(function(){
// var id = $(this).attr('id');
alert('it works');
});
有很多.spinner1类,但我想在each
类内的spinner1类上进行busket1
事件。我上面的jquery代码不起作用。我无法编写自己的代码来解决这个问题。有什么想法吗?
答案 0 :(得分:2)
你需要这样做。
$(function() {
$('.busket').find('.spinner1').each(function() {
alert('it works');
});
});
通过这种方式,它会在spinner1
中找到所有类busket
的元素