@Craken666

Скрытое содержимое появляется при обновлении страницы, что делать?

Суть такая:
При обновлении страницы или при переходи по ссылкам, у меня появляются скрытые страницы.

html
<?php if (isset($_SESSION['logged_user'])) : ?>
        <div class="prfileWrap">
          <ul class="profile-item">
            <a href="" onclick="return false;"><i class="fa fa-user-circle" aria-hidden="true"></i></a>
            <ul class="sub-profile">
              <li><a href="">Мои товары</a></li>
              <li><a href="">Выйти</a></li>
            </ul>
          </ul>
        </div>
      <?php endif; ?>

CSS
.prfileWrap {
	margin-top: -50px;
	margin-left: 87%;
	position: absolute;
	text-align: center;
}

.prfileWrap i {
	font-size: 25px;
	color: black;
}

.sub-profile {
	list-style: none;
}


При добавлении
display none
на клик меню не появляется

const elementsProfile = document.getElementsByClassName('profile-item');
for (i = 0; i < elementsProfile.length; i++){
	elementsProfile[i].addEventListener('mousedown', showMenu);
	elementsProfile[i].addEventListener('mouseleave', hideMenu);
}

function showMenu(){
	if (this.children.length > 1) {
		this.children[1].style.height = 'auto';
		this.children[1].style.opacity = '1';
		this.children[1].style.overflow = 'visible';
	}
}

function hideMenu(){
	if (this.children.length > 1) {
		this.children[1].style.height = '0';
		this.children[1].style.opacity = '0';
		this.children[1].style.overflow = 'hidden';
	}
}
  • Вопрос задан
  • 76 просмотров
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы