我试图用jQuery来定位id。不幸的是,它们嵌套在div中,我的jquery将无法工作。作为一个例子,我将如何定位:jQuery - 如何定位嵌套元素?
id="beds"
内
<div id="content">
<div class="page">
<form>
<select class="customSelect_beds" id="beds">
jQuery的
$(document).ready(function() {
$('#beds').change(multiply);
$('#baths').change(multiply);
$('#frequency').change(multiply);
function multiply() {
var beds = parseFloat($('#beds').val()),
baths = parseFloat($('#baths').val()),
baselight = 54,
bedmodlight = (beds * 12),
bathmodlight = (baths * 6),
basereg = 54,
bedmodreg = (beds * 18),
bathmodreg = (baths * 12),
basedeep = 72,
bedmoddeep = (beds * 24),
bathmoddeep = (baths * 18),
discount = $('#frequency').val(),
light_cleaning = Math.ceil((baselight + bedmodlight + bathmodlight) * discount),
regular_cleaning = Math.ceil((basereg + bedmodreg + bathmodreg) * discount),
deep_cleaning = Math.ceil((basedeep + bedmoddeep + bathmoddeep) * discount);
$('#total_light').text((light_cleaning) || "--");
$('#total_regular').text((regular_cleaning) || "--");
$('#total_deep').text((deep_cleaning) || "--");
};
}); 我似乎无法在任何地方找到此信息(虽然我仍在寻找)。有小费吗?
编辑 - 代码添加和截断的空间。
不知道为什么我得到downvoted不知道东西.. – user2635811