Поскольку стиль элемента не maxheight === 0. Это вычисляемый стиль maxheight 0, что не одно и то же. Вы можете либо присвоить стиль элементу, либо изменить свое состояние, чтобы проверить, является ли максимальная высота 1000. Любой из них будет работать.
function slide() {
if (parseInt(document.getElementById("sliding").style.maxHeight) === 0) {
document.getElementById("sliding").style.maxHeight = "1000px";
} else {
document.getElementById("sliding").style.maxHeight = "0px";
}
}
#sliding {
transition: 0.5s;
max-height: 0px;
overflow: hidden;
}
<button onclick="slide();" class="btn btn-primary">READ</button>
<div id="sliding" style="max-height: 0">
<p>
What is Lorem Ipsum? Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type
specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently
with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</div>
Или
function slide() {
if (parseInt(document.getElementById("sliding").style.maxHeight) !== 1000) {
document.getElementById("sliding").style.maxHeight = "1000px";
} else {
document.getElementById("sliding").style.maxHeight = "0px";
}
}
#sliding {
transition: 0.5s;
max-height: 0px;
overflow: hidden;
}
<button onclick="slide();" class="btn btn-primary">READ</button>
<div id="sliding">
<p>
What is Lorem Ipsum? Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type
specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently
with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</p>
</div>