-1

我正在尝试使用 jquery 来定位 id。不幸的是,它们嵌套在 div 中,我的 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) || "--");
};

}); 我似乎无法在任何地方找到此信息(尽管我仍在寻找)。有小费吗?

编辑 - 添加并截断空间的代码。

4

2 回答 2

1

尝试这个 :

$('#content').find('#beds');
于 2013-08-29T08:25:37.237 回答
1

因为你有一个 id 你可以使用id-selector

$('#beds')
于 2013-08-29T08:30:43.277 回答