Показать сообщение отдельно
  #1 (permalink)  
Старый 14.05.2023, 03:55
Профессор
Отправить личное сообщение для Сергей Ракипов Посмотреть профиль Найти все сообщения от Сергей Ракипов
 
Регистрация: 01.06.2010
Сообщений: 668

Математика в JS
Есть вот такая верстка

<style>

body {
  font-family: monospace;
  font-size: .8rem;
}

main {
  max-width: 720px;
  margin: 0 auto;
}

section{
  max-width: 480px;
  margin: 0px auto 0px;
}
.total_all {
  margin: 40px 0px 40px 0px;
  font-size: 2rem;
}
.summa__1 {
  margin: 40px 0px 0px 0px;
  font-size: 1.2rem;
}
.number_1 {
  padding: 0px 0px 0px 20px;
}
.summa__2 {
  margin: 40px 0px 0px 0px;
  font-size: 1.2rem;
}
.number_2 {
  padding: 0px 0px 0px 20px;
}
.summa__3 {
  margin: 40px 0px 0px 0px;
  font-size: 1.2rem;
}
.number_3 {
  padding: 0px 0px 0px 20px;
}
.summa__4 {
  margin: 40px 0px 0px 0px;
  font-size: 1.2rem;
}
.number_4 {
  padding: 0px 0px 0px 20px;
}
</style>
<body>

<section>

	<div class="total_all">32 000</div>

	<div class="summa__1">
		<label class="container">8 000
			<input type="checkbox" checked="checked">
			<span class="checkmark"></span>
		</label>
	</div>
	<div class="number_1">
		<label class="container">2 000
			<input type="checkbox" checked="checked">
			<span class="checkmark"></span>
		</label>
	</div>
	<div class="number_1">
		<label class="container">2 000
			<input type="checkbox" checked="checked">
			<span class="checkmark"></span>
		</label>
	</div>
	<div class="number_1">
		<label class="container">2 000
			<input type="checkbox" checked="checked">
			<span class="checkmark"></span>
		</label>
	</div>
	<div class="number_1">
		<label class="container">2 000
			<input type="checkbox" checked="checked">
			<span class="checkmark"></span>
		</label>
	</div>

	<div class="summa__2">
		<label class="container">8 000
			<input type="checkbox" checked="checked">
			<span class="checkmark"></span>
		</label>
	</div>
	<div class="number_2">
		<label class="container">2 000
			<input type="checkbox" checked="checked">
			<span class="checkmark"></span>
		</label>
	</div>
	<div class="number_2">
		<label class="container">2 000
			<input type="checkbox" checked="checked">
			<span class="checkmark"></span>
		</label>
	</div>
	<div class="number_2">
		<label class="container">2 000
			<input type="checkbox" checked="checked">
			<span class="checkmark"></span>
		</label>
	</div>
	<div class="number_2">
		<label class="container">2 000
			<input type="checkbox" checked="checked">
			<span class="checkmark"></span>
		</label>
	</div>

	<div class="summa__3">
		<label class="container">8 000
			<input type="checkbox" checked="checked">
			<span class="checkmark"></span>
		</label>
	</div>
	<div class="number_3">
		<label class="container">2 000
			<input type="checkbox" checked="checked">
			<span class="checkmark"></span>
		</label>
	</div>
	<div class="number_3">
		<label class="container">2 000
			<input type="checkbox" checked="checked">
			<span class="checkmark"></span>
		</label>
	</div>
	<div class="number_3">
		<label class="container">2 000
			<input type="checkbox" checked="checked">
			<span class="checkmark"></span>
		</label>
	</div>
	<div class="number_3">
		<label class="container">2 000
			<input type="checkbox" checked="checked">
			<span class="checkmark"></span>
		</label>
	</div>

	<div class="summa__4">
		<label class="container">8 000
			<input type="checkbox" checked="checked">
			<span class="checkmark"></span>
		</label>
	</div>
	<div class="number_4">
		<label class="container">2 000
			<input type="checkbox" checked="checked">
			<span class="checkmark"></span>
		</label>
	</div>
	<div class="number_4">
		<label class="container">2 000
			<input type="checkbox" checked="checked">
			<span class="checkmark"></span>
		</label>
	</div>
	<div class="number_4">
		<label class="container">2 000
			<input type="checkbox" checked="checked">
			<span class="checkmark"></span>
		</label>
	</div>
	<div class="number_4">
		<label class="container">2 000
			<input type="checkbox" checked="checked">
			<span class="checkmark"></span>
		</label>
	</div>

</section>

<script>
const num = parseInt(document.querySelector('.total_all').innerHTML.replace(/\s/g, ''));
const summa__1 = parseInt(document.querySelector('.summa__1>.container').innerHTML.replace(/\s/g, ''));
const number_1 = parseInt(document.querySelector('.number_1>.container').innerHTML.replace(/\s/g, ''));
</script>
</body>
Ответить с цитированием