Я хочу применить некоторый стиль, если мышь нажата внутри элемента (здесь .block
). Если элемент щелкнут, получите этот элемент $(this)
и создайте его. Теперь после этого, когда пользователь нажимает кнопку, отличную от элемента $(this)
, я хотел бы изменить его на стиль по умолчанию. Как определить, нажата ли мышь, кроме элемента $(this)
.
js script:
$( document ).ready(function() {
// when a block is clicked get that specific block
$('.block').click(function() {
var block = $(this);
block.css('background','red');
});
//if clicked other than the block do stuff
});