How can I calculate sum of elements (container html)?

How can I calculate sum of elements (container html)?

Hi! I have a big container (BC) which containts many containers (MC) and some buttons. MC also containts some numberfields, container with sum of these numberfields (SN) and some buttons which are coupled in another container. I need to calculate final sum of SN for each MC.