<script type="text/javascript">
$(document).ready(function () {
// $('.ratestar').rating();
$('.ratestar').rating(function (vote, event) {
//alert(vote);
var id = $(this).attr('id');
alert(id);
// write your ajax code here
$.ajax({
url: '@Url.Action("RequestQuoteAll_ajax", "Engineer")',
data: { CompanyID: ComapnyID },
type: 'POST',
success: function (data) {
data;
}
});
// For example;
// $.get(document.URL, {vote: vote});
});
});
</script>
[Route("~/personphoto/{id:Guid}/{sizes?}/{size?}")]
public IHttpActionResult GetPhoto(Guid id, string sizes = "", string size = "")
我有6个具有相同类别的单选按钮,当循环运行多次时,我无法获得当前的div id。
答案 0 :(得分:1)
<!--KEEP DYNAMIC ID -->
<div class="ratestar" id="<Here_Dynamic_Id>" >
// YOU WILL GET THE DYNAMIC ID OF ONLY THAT DIV WHICH WILL BE CLICKED
var strCurrentDivId = $(this).attr('id');
答案 1 :(得分:0)
请尝试以下代码。这将带您到父div并给出id
var id = $(this).closest('div.ratestar').attr('id');
alert(id);