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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91
| <!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Page Title</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/latest/jquery.mobile.min.css"/>
<script src="http://code.jquery.com/jquery-1.6.2.min.js"></script>
<script src="http://code.jquery.com/mobile/latest/jquery.mobile.min.js"></script>
</head>
<body>
<div data-role="page">
<div data-role="header">
<h1>Page 1</h1>
</div>
<div data-role="content">
<h2>Page 1</h2>
<div data-role="fieldcontain">
<fieldset data-role="controlgroup">
<legend>recherche par categorie</legend>
<input type="checkbox" name="categories" id="categories" class="custom" />
<label for="categories">selectionner Tout/ Deselectionner Tout</label>
<input type="checkbox" name="categories" id="restaurant" class="custom" />
<label for="restaurant">Restaurant</label>
<input type="checkbox" name="categories" id="detente" class="custom" />
<label for="detente">Detente/soin</label>
<input type="checkbox" name="categories" id="loisirs" class="custom" />
<label for="loisirs">Loisirs </label>
<input type="checkbox" name="categories" id="achats" class="custom" />
<label for="achats">Achats</label>
<input type="checkbox" name="categories" id="voyages" class="custom" />
<label for="voyages">Voyages </label>
<input type="checkbox" name="categories" id="services" class="custom" />
<label for="services">Services </label>
</fieldset>
</div>
</div>
<div data-role="footer">
<h1>Footer</h1>
</div>
</div>
<script>
$(window).load(function(){
/*
* Cocher ou décocher tous les checkbox
* contenu dans le fieldset.
*/
$("#categories").change(function(){
var objParent = $(this).parents("fieldset"),
objsInput = objParent.find("input[type='checkbox']"),
objsLabel = objParent.find("label[for]"),
boolChecked = $(this).prop("checked");
objsInput.prop("checked", boolChecked);
if (boolChecked){
objsLabel.removeClass("ui-checkbox-off").addClass("ui-checkbox-on");
$.each(objsLabel.children(), function(i, item){
$(item).children().each(function(j, jtem){
if (j == 1){
$(jtem).removeClass("ui-icon-checkbox-off").addClass("ui-icon-checkbox-on");
}
});
});
} else {
objsLabel.removeClass("ui-checkbox-on").addClass("ui-checkbox-off");
$.each(objsLabel.children(), function(i, item){
$(item).children().each(function(j, jtem){
if (j == 1){
$(jtem).removeClass("ui-icon-checkbox-on").addClass("ui-icon-checkbox-off");
}
});
});
}
});
});
</script>
</body>
</html> |
Partager