2

.toggle() вырезали в 1.9, но сейчас не много по другому он работает. Я еще не доучил чистый js и только знакомлюсь с jQuery.

2 ответа 2

2
$(".example").toggleClass("bounce")

http://api.jquery.com/toggleclass/

1
0

На javascript

var elementButton = document.querySelector('button'),
    elementSquare = document.querySelector('.square');

elementButton.onclick = function() {
    elementSquare.classList.toggle('circle');
}
body{
  padding-top: 45px;
}
.square {
    margin: 25px auto;
    height: 100px;
    width: 100px;
    background: #ccc;
    transition: .3s;
}

.circle {    
    border-radius: 50%;
}

button{
  padding: 15px 45px;
  font-size: 20px;
}
<button>Button</button>

<div class="square"></div>

Ваш ответ

By clicking “Отправить ответ”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Всё ещё ищете ответ? Посмотрите другие вопросы с метками или задайте свой вопрос.