I’m trying to get the closest ancestor element to a clicked element, from an array of provided elements. When a user clicks on a tab, I need to find out where on the page that tab is.
I have something kind of working, however this script thinks main is the closest tag, when it should be article.
If I put article before main in the array it works just fine, however I wan’t this to work regardless of array order. Any ideas?
// Tab Click
var tabs = Array.from(document.querySelectorAll('details.company-details'));
function handleTabClick(e) {
var tabNode = e.target;
tabLabel = tabNode.innerText;
const tgt = e.target;
var location;
var elements = ['section', 'header', 'main', 'nav', 'article'];
for (let element of elements) {
if (tgt.closest(element)) {
location = element;
break;
};
}
console.log(location);
};
tabs.forEach(function(tab) {
tab.addEventListener('click', handleTabClick);
});
<main class="company-main-wrapper" id="maincontent">
<article>
<div class="company-grid-row">
<div class="company-grid-column-two-thirds">
<div class="company-page-content">
<div class="block-expander">
<details class="company-details company-expander" company-polyfilled="true" id="company-details0" open="">
<summary class="company-details__summary" role="button" aria-controls="company-details__text0" tabindex="0" aria-expanded="true">
<span class="company-details__summary-text">
sampoe page
</span>
</summary>
</details>
</div>
</div>
</div>
</div>
</article>
</main>
provigil online – modafinil 200 mg modafinil and weight loss
accutane online – buy isotretinoin order accutane canada
buy cheap vardenafil no prescription – vardenafil prices vardenafil for sale
amoxicillin without prescription – buy amoxicilin 500 mg online amoxicillin 500mg capsules
purchase cialis online cheap
ivermectin 500ml – buy stromectol canada ivermectin buy nz
provigil schedule – provigil settlement modafinil reviews
buy zithromax – can you buy zithromax zithromax antibiotic zithromax
furosemide 25 mg – lasix purchase furosemide costs
buy clomid online – buy clomid online where can i buy clomid
buy generic cialis 5mg – real cialis cheap tadalafil price
purchase stromectol online – ivermectin over the counter canada ivermectin tablets for sale walmart
play for real online casino games – best online casino usa real casino online
erectile dysfunction medicine – medication for ed dysfunction drugs for ed
buy prednisone online canada – predisone with no presciption where to buy prednisone tablets
how much is female viagra – buy genuine viagra online uk sildenafil 20 mg pill
cialis online without prescription – Discounted cialis online cross border pharmacy canada
ivermectin dose for covid – stromectol for sale ivermectin uk
ed pills – ed treatment review ed medication online
Cialis Necesita Receta
Cialis
https://buypropeciaon.com/ – what does propecia do
Good article. I will be facing some of these issues as well..
https://buytadalafshop.com/ – cialis pills
Viagra
Hi there! I’m at work surfing around your blog from my new apple iphone!
Just wanted to say I love reading through your blog and look forward to all your posts!
Carry on the superb work!
http://buysildenshop.com/ – Viagra
Thanks very nice blog!
This is a topic which is near to my heart… Thank you!
Exactly where are your contact details though?
WOW just what I was searching for. Came here by
searching for an
My brother recommended I may like this web site. He was once totally right.
This post actually made my day. You can not believe just how much time I had spent for this information! Thanks!
stromectol ivermectin tablets
Very good blog! Do you have any tips for aspiring writers?
I’m planning to start my own website soon but I’m a little
lost on everything. Would you recommend starting with a free platform like
Wordpress or go for a paid option? There are so many choices out
there that I’m completely confused .. Any recommendations?
Many thanks!
cialis comprar espana
furosemide 40 mg tablet buy online lasix medicine price nek nox
furosemide prescription cost of lasix nek nox
Canadian Pharmacy Viagra 100
Wow, incredible blog structure! How lengthy have you been running a blog for?
you make running a blog glance easy. The full look of your website is wonderful, let alone the content material!
scoliosis surgery https://0401mm.tumblr.com/ scoliosis surgery
You really make it seem really easy along with your presentation but
I find this topic to be really something which I believe
I’d by no means understand. It kind of feels too complex and extremely huge for me.
I’m taking a look ahead in your next put up, I’ll try to get the grasp of it!
asmr https://app.gumroad.com/asmr2021/p/best-asmr-online asmr
furosemide 40 mg cost goodrx lasix nek nox
Amazing! Its really amazing paragraph, I have got
much clear idea regarding from this paragraph.
scoliosis surgery https://coub.com/stories/962966-scoliosis-surgery scoliosis surgery
https://buystromectolon.com/ – stromectol without prescription
Good post. I learn something totally new and challenging on websites I stumbleupon on a daily basis.
It’s always interesting to read articles from other writers and practice a little
something from other web sites. cheap flights http://1704milesapart.tumblr.com/ cheap flights
http://buyzithromaxinf.com/ – Zithromax
http://buyplaquenilcv.com/ – Plaquenil
ivermectin 5 mg price stromectol covid 19
Zithromax
Lasix
stromectol liquid best price on ivermectin pills
Priligy
http://buylasixshop.com/ – Lasix
Cialis Online No
get clomid over the counter nek nox
clomid prescription online nek nox
cialis de 10 o de 20
stromectol price ivermectin over the counter
Venta De Kamagra Online
https://prednisonebuyon.com/ – can you take tylenol with prednisone
Neurontine
buy prednisone 10mg no prescription
https://buyneurontine.com/ – is gabapentin
Cheap Amoxicillin Online
Hi there, You have done a fantastic job. I’ll certainly digg it and personally suggest
to my friends. I’m confident they’ll be benefited from this website.
ivermectin 6 tablet – ivermectin 3 mg stromectol ivermectin 9 mg
Cialis
Viagra
Foros Sobre Priligy
Cialis
deltasone over the counter – prednisone 40 mg tablets buy prednisone nz
generic propecia no perscription
levitra commander