Last active
April 10, 2020 17:40
-
-
Save arsho/d6fe9c3e1759f2a080aba614da25c335 to your computer and use it in GitHub Desktop.
Count child elements using jQuery. Count number of Upazilas of Bangladesh from: https://bangladesh.gov.bd/site/view/upazila-list/%E0%A6%89%E0%A6%AA%E0%A6%9C%E0%A7%87%E0%A6%B2%E0%A6%BE-%E0%A6%B8%E0%A6%AE%E0%A7%82%E0%A6%B9
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var count = 0; | |
$(".child-domains").each(function(index) | |
{ | |
$this = $(this); | |
children_length = $this.find('a').length; | |
count += children_length; | |
} | |
); | |
console.log("Total = ", count); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$count_section = 1; | |
$count_subsection = 1; | |
$self_service = ""; | |
$third_party = ""; | |
$(".table tr").each(function(item, data){ | |
$tr = $(this); | |
if($tr.attr("class") == "active"){ | |
$section_title = $tr.children("td:first").text(); | |
console.log($count_section+".#### "+$section_title+":") | |
$count_section++; | |
$count_subsection = 1; | |
} | |
else{ | |
$subsection_title = $tr.children("td:first").text(); | |
console.log(" "+$count_subsection+". <b>"+$section_title+"</b>: "+$value); | |
$count_subsection++; | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment