Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

163
Views
JavaScript on Website can't "select" element

i recently started reworking my website, mainly adding features or rewriting code. Now, I wanted to add a socials-page (with my social-media links) and i want my JavaScript to import the cards from a JSON-document. For that, i need to select the socialsTitle, socialsLink, socialsLinkDisplay and socialsIcon-elements to put in their values. For selecting those elements. I did this, but the only element that's just returning null is the socialsLink.

JS:

const socialsTitle = socialsCard.querySelector("[socialsTitle]");
const socialsLink = socialsCard.querySelector("[socialsLink]");
const socialsLinkDisplay = socialsCard.querySelector("[socialsLinkDisplay]");
const socialsIcon = socialsCard.querySelector("[socialsIcon]");

HTML:

<template socialsTemplate>
    <a target="_blank" class="card socialsElement" socialsLink>
        <img alt="" class="appIcon socialsElement" socialsIcon />
        <h1 class="appDetails socialsElement">
            <p class="appName socialsElement" socialsTitle></p>
            <p class="appLink socialsElement" socialsLinkDisplay></p>
        </h1>
    </a>
</template>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

I believe socialsCard is the element having socialsLink attribute. querySelector is for looking up children nodes within the element you call it on.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!