Skip to main content

Posts

Showing posts from September, 2016

Javascript Search in Object Array Like SQL By Object Key

var keywords = [     {"keyword": "Sample 1", "item": {"title":"Sample Title", "url": "/sample"}},     {"keyword": "Foo 1", "item": {"title":"Foo Title", "url": "/sample"}} ]; $("#query").on('keyup', function() {     var search = this.value.toLowerCase();     var result = $.grep(keywords, function(el) {         return el.keyword.toLowerCase().indexOf(search) > -1;     });         log(result) }); function log(rows) {     var str = '';     $.each(rows, function(i, row) {         str += JSON.stringify(row) + '<br>';     });     $('#log').html(str); }

Hide a column of table with jquery

<table> <thead> <td><input type = "checkbox" checked = "checked" /></td> <td><input type = "checkbox" checked = "checked" /></td> <td><input type = "checkbox" checked = "checked" /></td> <td><input type = "checkbox" checked = "checked" /></td> <td><input type = "checkbox" checked = "checked" /></td> </thead> <tbody> <tr> <td> column 1 </td> <td> column 2 </td> <td> column 3 </td> <td> column 4 </td> <td> column 5 </td> </tr> </tbody> </table> $(document).on('change', 'table thead input', function() { var checked = $(this).is(":checked"