Tôi có nhiều checkboxs như dưới đây,Sử dụng jQuery để nhận giá trị và đầu ra của nhiều hộp kiểm dưới dạng Chuỗi phân cách bằng dấu phẩy.
<li><input type="checkbox" name="areaofinterest" value="home_coo" id="home_coo" class="Checkbox" > Cooking</li>
<li><input type="checkbox" name="areaofinterest" value="home_cra" id="home_cra" class="Checkbox"> Crafts</li>
<li><input type="checkbox" name="areaofinterest" value="home_dec" id="home_dec" class="Checkbox"> Decorating</li>
<li><input type="checkbox" name="areaofinterest" value="home_ent" id="home_ent" class="Checkbox"> Entertaining</li>
<li><input type="checkbox" name="areaofinterest" value="home_gar" id="home_gar" class="Checkbox"> Gardening</li>
<li><input type="checkbox" name="areaofinterest" value="home_hom" id="home_hom" class="Checkbox"> Home Improvement</li>
<li><input type="checkbox" name="areaofinterest" value="home_mar" id="home_mar" class="Checkbox"> Marriage</li>
<li><input type="checkbox" name="areaofinterest" value="home_par" id="home_par" class="Checkbox"> Parenting</li>
<li><input type="checkbox" name="areaofinterest" value="home_pet" id="home_pet" class="Checkbox" > Pets</li>
<li><input type="checkbox" name="areaofinterest" value="home_ret" id="home_ret" class="Checkbox"> Retirement</li>
Làm thế nào tôi có thể sử dụng jQuery để có được những giá trị và sản lượng kiểm tra như areaofinterest = "home_coo, home_mar, home_pet"?
Cảm ơn rất nhiều.
Wow ... Tuyệt vời .... Cảm ơn một nghìn ... – Frank
Chỉ cần một FYI - "," trong tham gia là không cần thiết vì nó sẽ thêm dấu phẩy theo mặc định khi chỉ sử dụng 'join()'. Cũng cần lưu ý, đây là kịch bản chính xác mà jQuery sử dụng trong các tài liệu cho '.map()': http://api.jquery.com/map/ – Roi
[Bản cập nhật được cập nhật] (http://jsfiddle.net/ Nr2zU/683 /): Tạo chuỗi phân tách bằng dấu phẩy, lưu chuỗi, sau đó sử dụng chuỗi để khôi phục các hộp kiểm. – Patrick