bonjour,
ton code est un peu difficile a lire surtout avec .parent().parent().parent()...
tout d'abord il faut ajouter un span dans .hida1
<dt class="hida1"><span>Select 1</span></dt>
.
j'ai rectifié un peu le code :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
|
//Toggle de la liste
$(".multiple-choix").on("click",".hida1", function() {
$(".mutliSelect1 ol").not($(".mutliSelect1 ol", $(this).parent())).slideUp('500');
$(".mutliSelect1 ol", $(this).parent()).slideToggle('500');
});
//Reporter valeur
$(".multiple-choix").on("change", ".mutliSelect1 ol input[type='checkbox']", function() {
//variables
var p = $(".hida1 span, p.choix_membre ");/*ici p.choix_membre et pas : .choix_membre p */
var string = ' ';
//pour chaque checkbox dont la valeur est true
$(".mutliSelect1 ol input[type='checkbox']").each(function() {
if ($(this).is(':checked')) {
string = string + $(this).val() + ', ';
}
});
//decoupage de la virgule
newstring = string.substring(0, string.lastIndexOf(','));
if (newstring == '') {
newstring = 'Select';
}
p.html(newstring);
$('.choix_membre').text(newstring);
}); |
Partager