This bit of code works fine, but on the iPad it is a bit slow the opening. Basically I have a set of divs with class .item
and when I click on one of them I need to add a class called .is-expanded
and open the box while closing the others if any was opened. The boxes have an image, on click it should be fast to hide it and open the selected box. This works fine on the computer while on the iPad the whole thing is a bit slow delays. Is there anyway to make it quicker or am I doing anything which makes it slow?
Html:
<div class="item">
<img .. />
<div class="wrapVideo">..</div>
</div>
<div class="item">
<img .. />
<div class="wrapVideo">..</div>
</div>
<div class="item">
<img .. />
<div class="wrapVideo">..</div>
</div>
Jquery:
$(document).on( 'click', '.item:not(.is-expanded)', function() {
$(".item").removeClass('is-expanded');
$(".wrapVideo").css("display", "none");
$("img").css("display", "block");
$(this).addClass('is-expanded');
$("img", this).css("display", "none");
$(".wrapVideo", this).show();
);