I assigned a pseudo-class div a :active
CSS so that it "reacts" to clicks and tags.
.quarter:active{
opacity: 0.5;
}
What I want to achieve is simulating a long click using jQuery.
.trigger("click")
doesn't seem to do the trick, as there is no visible discoloration. I also tried with .trigger("focus")
and .trigger("mousedown")
, but it seems like I messed up somewhere.
<div id="1" class="quarter green" ></div>
<div id="2" class="quarter red" ></div>
<div id="3" class="quarter yellow" ></div>
<div id="4" class="quarter blue" ></div>
Is there a way to achieve this, or do I need to use an approach toggleClass
?
Edit: Thanks to nashcheez responder, I solved my problem using .trigger("focus")
, and then setTimeout(...{ .blur() })
. Thanks to everyone for the quick answers.
source
share