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

281
Views
My simple custom JavaScript component not working in HTML?

I defined my component in "component.js" like this:

class LeftSideMenu extends HTMLElement {
    connectedCallBack() {
        this.innerHTML =
        `
        ---my HTML codes---
        `
    }
}
customElements.define("left-side-menu", LeftSideMenu);

But when I try to use my component in HTML page, it doesn't show my component.

in head tag:

<script src="component.js"></script>

in body:

<left-side-menu></left-side-menu>

What is wrong? In another project, I wrote exactly like this and it had worked.

EDIT: Whole HTML:

<!doctype html>
<html class="no-js" lang="en">

<head>
    <meta charset="utf-8">
    <meta http-equiv="x-ua-compatible" content="ie=edge">
    <title>Admin Panel</title>
    <meta name="description" content="">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" type="image/x-icon" href="img/favicon.ico">
    <link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,700,900" rel="stylesheet">
    <link rel="stylesheet" href="style.css">
</head>
<body>
    <!--[if lt IE 8]>
        <p class="browserupgrade">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
    <![endif]-->
    <!-- Start Left menu area -->
    <left-side-menu></left-side-menu>
    <!-- End Left menu area -->
    <div> Header div </div>
    <div> Page div </div>
    <!-- scripts -->
    <script src="component.js"></script>
</body>

</html>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

connectedCallBack is written wrong, the b has to be lowercase:

connectedCallback

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!