I am knew to JavaScript/JQuery. I need to filter (show/hide) lines by chosen option(All - show all rows, Closed - hide all options except Closed, Open - only 'Open' rows.).
Where I do something wrong? I want to understand it. my code:
.html:
<select class="select">
<option>All</option>
<option>Closed</option>
<option>Open</option>
</select>
<div class="btn">
<input id='status-filter' type="submit" value="Ok"/>
...
<tr class='row' data-row-choice="All">
<tr class='row' data-row-choice="All">
<tr class='row' data-row-choice="Open">
...
.js:
$( document ).ready(function() {
$('.btn').on('click', '#status-filter', function() {
var selectOption = $('#select option:selected').text();
$('.order').each(function(selectOption) {
if ($('.order[data-row-choice]') == 'All') {
$(this).show();
} else if ($('.order[data-order-choice]') != selectOption) {
$(this).hide();
};
});
});
});
Aucun commentaire:
Enregistrer un commentaire