M index.html => index.html +1 -1
@@ 45,7 45,7 @@
<label><input type="checkbox" value=12>12 Mpx</label>
<label><input type="checkbox" value=15>15 Mpx</label>
</div>
- <button>Clear filters</button>
+ <button type="button" onclick="clearFilters()">Clear filters</button>
</form>
</div>
</div>
M js/app.js => js/app.js +13 -0
@@ 113,6 113,19 @@ function filterListener(par) {
applyFilters();
}
+function clearFilters() {
+ var inputs = document.getElementsByTagName('input');
+ for (var k in inputs) {
+ var input = inputs[k];
+ if (typeof input !== 'object') continue;
+
+ input.checked = false;
+ input.onchange();
+ }
+
+ applyFilters();
+}
+
document.addEventListener('DOMContentLoaded', function() {
ajax('products.json', function(dict) {
phoneDetails = dict;