Stack Overflow Asked by Turqay Umudzade on October 2, 2020
I have 2 events here one is click
and one is focus
on the input, I need the click to run before focus so I added a timeout to it but I feel like this isn’t an elegant solution.
$(document).click(function(e) {
var target = e.target;
var lastElement = '#' + lastList;
console.log('here first');
if (!$(target).is(lastElement) && !$(target).parent().parent().is(lastElement) && !$(target).parent().parent().parent(lastElement).is(lastElement)) {
$('.add-card .fa-plus').show();
$(lastElement).children().children().children('textarea').addClass('pl-8 bg-gray-200');
$(lastElement).children().children().children('textarea').removeClass('h-20 px-4 w-60 resize bg-white');
$('.js-add-card-button').addClass('hidden')
}
});
$(document).on('focus', '.js-create-card', function(e) {
setTimeout(() => {
console.log('here');
$(this).siblings('.add-card .fa-plus').hide();
$(this).removeClass('pl-8 bg-gray-200');
$(this).addClass('h-20 px-4 w-60 resize bg-white');
$(this).siblings('.js-add-card-button').removeClass('hidden');
lastList = $(this).parent().parent().parent().attr('id');
}, 100);
});
So I have a few questions about the solution I used:
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP