I'm working on jQuery selector and getting this trouble:
<div class="pull-left">
<span class="fa fa-circle"></span>
<a class="name" href="#">User name</a>
</div>
pull-left class has the width 180px and name class has the width ~ 80px.
I want to write an event for pull-left class (except name class). I've tried:
$event.chatwindow = {
resize: function () {
let _this = $(this),
chatwindow = _this.closest('.chat-window'),
body_content = chatwindow.find('.body-content');
// test while clicking on <a> tag
// but always getting:
// <div class"pull-left">...</div>
$log(this);
// avoid to click <a> tag
if (!_this.hasClass('name')) {
if (!body_content.hasClass('hidden')) {
body_content.addClass('hidden');
} else {
body_content.removeClass('hidden');
}
}
}
};
$(document).on('click', '.chat-window .header .pull-left', $event.chatwindow.resize);
But when I tried to click on the a tag, the window was still hidden/shown.
How can I run the event while clicking on pull-left div but avoiding <a> tag?
Thank you!