Đếm số lần xuất hiện của số trong từng dòng 26/08/2020 | Cập nhật: 26/08/2020 Kelvin Khanh 83 Có thể bạn thích ? Quá trình chuyển đổi sang HTTPS của ThichCode.NET (dùng host Blogger) Tạo background dạng text cho Blog (website) bằng Jquery Chống click tặc cho adsense bằng javascript htmlcssjsdownloadDemoCode by ThichCode.NET <textarea id='str' style='width:100%;min-height:200px'> 04,40,14,41,24,42,34,43,44,54,45,64,46,74,47,84,48,94,49,09,90,19,91,29,92,39,93,59,95,69,96,79,97,89,98,99,03,30,13,31,23,32,33,53,35,63,36,73,37,83,38,08,80,18,81,28,82,58,85,68,86,78,87,88 04,40,14,41,24,42,34,43,44,54,45,64,46,74,47,84,48,94,49,09,90,19,91,29,92,39,93,59,95,69,96,79,97,89,98,99,02,20,12,21,22,32,23,52,25,62,26,72,27,82,28,07,70,17,71,37,73,57,75,67,76,77,87,78 01,10,11,21,12,31,13,41,14,51,15,61,16,71,17,81,18,91,19,06,60,26,62,36,63,46,64,56,65,66,76,67,86,68,96,69,03,30,23,32,33,43,34,53,35,73,37,83,38,93,39,08,80,28,82,48,84,58,85,78,87,88,98,89 01,10,11,21,12,31,13,41,14,51,15,61,16,71,17,81,18,91,19,02,20,22,32,23,42,24,52,25,62,26,72,27,82,28,92,29,08,80,38,83,48,84,58,85,68,86,78,87,88,98,89,09,90,39,93,49,94,59,95,69,96,79,97,99 02,20,12,21,22,32,23,42,24,52,25,62,26,72,27,82,28,92,29,03,30,13,31,33,43,34,53,35,63,36,73,37,83,38,93,39,04,40,14,41,44,54,45,64,46,74,47,84,48,94,49,05,50,15,51,55,65,56,75,57,85,58,95,59 06,60,16,61,26,62,36,63,46,64,56,65,66,76,67,86,68,96,69,07,70,17,71,27,72,37,73,47,74,57,75,77,87,78,97,79,08,80,18,81,28,82,38,83,48,84,58,85,88,98,89,09,90,19,91,29,92,39,93,49,94,59,95,99 </textarea> <br/><br/> <button id='TimSoLanXuatHien'>Tìm số lần xuất hiện</button> <div id='KetQuaTimSoLanXuatHien'></div> <script src="//ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script type="text/javascript"> $(function() { $('button#TimSoLanXuatHien').click(function(){ var arr_all = $('textarea#str').val().split('\n'); var arr_item_count = []; for(var i=0;i<arr_all.length + 1;i++) { arr_item_count.push([]); } var count = 0; var tmp = ''; for (var i = 0; i < arr_all.length; i++) { var arr_item = arr_all[i].split(','); for (var j = 0; j < arr_item.length; j++) { tmp = arr_item[j]; for (var k = 0; k < arr_all.length; k++) { if (arr_all[k].includes(tmp)) { count = count + 1; } } if (!arr_item_count[count].includes(tmp)) arr_item_count[count].push(tmp); count = 0; tmp = ''; } } $('div#KetQuaTimSoLanXuatHien').empty().append('<br/>'); for(var i=0;i<arr_item_count.length;i++) { $('div#KetQuaTimSoLanXuatHien').append('Xuất hiện ' + i + ' => ' + arr_item_count[i].sort() + '<br/>'); } }); }); </script> Result