Why isn't my ... running?

I am trying to create a div where if I click it, it will show an inner div and upon clicking it again it will be hidden.

So I added the function and the a href around the div and it doesn't run at all just shows javascript:void(0) upon click at bottom-left corner.

<a onclick="openOverviewDiv(this)" href="javascript:void(0);">

if I remove the " at the end of href it will run. It a syntax error(noticed cause i left the " out on accident when i ran on local server) and then I added the " back and it stop running.

<a onclick="openOverviewDiv(this)" href="javascript:void(0);>

I've tried in the snippet and the same thing occurred. How do I fix this?

Update -- To Clarify: I am trying pass this.anchorElement upon clicking the anchor tag as shown above into the function openOverviewDiv(this).

onclick="openOverviewDiv(this)"

in which it then use jQuery to make the hidden children element of the anchor tag, which is a div with the class of "innerProjectDiv" and make it from display: none; to display:block;

jQuery(anchor).children("div.innerProjectDiv").show();

This should works for the anchor clicked and not for the rest of the other anchors' children. If i clicked the anchor with a project div called placeholder1, it should show me the hidden "div.innerProjectDiv" element and not other divs(ie. placeholder2).

If you copied the snippet, it doesn't run upon clicked and as stated if you remove the ", it will run.

function openOverviewDiv(anchor) {
  jQuery(anchor).children("div.innerProjectDiv").show();
  jQuery(anchor).children("i.fa").html("&#xf106;");
}
html,
body {
  height: 100%;
  width: 100%;
  background-color: #020224;
  color: white;
  margin: 0;
  padding: 0;
  min-height: 100%;
}

.container {
  display: grid;
  grid-template-rows: auto 1fr auto;
  grid-template-columns: 100%;
  min-height: 100vh;
  grid-template-areas: "nav" "content" "contentTwo" "footer"
}

.section {
  color: #fff;
  padding: 10px;
}


/* NAV CONTENT */

.nav {
  grid-area: nav;
  position: sticky;
  background-color: transparent;
  top: 0;
  left: 0;
  right: 0;
  display: grid;
  grid-template-columns: auto auto;
  z-index: 1;
  height: 5vh;
}

.nav a:link,
.nav a:visited {
  color: white;
  text-decoration: none;
}

.nav a:hover {
  color: cyan;
}

.navLeft {
  font-size: 2em;
  text-align: left;
}

.navRight {
  font-size: 1.5em;
  text-align: right;
}

.navRight a {
  padding-left: 10px;
}


/* CONTENT */

.homePG {
  grid-area: content;
  margin: auto;
  text-align: center;
  font-size: 7vw;
  padding: 10px 30px;
}

.homePG img {
  width: 500px;
  height: 500px;
}

.homePG h1 {
  font-size: 1em;
}

.homePG p {
  font-size: 0.5em;
}

.contentTwo {
  grid-area: contentTwo;
  margin: auto;
  text-align: center;
  font-size: 7vw;
  padding: 10px 30px;
}

.sidebar2 {
  grid-area: sidebar2;
}


/* IN-PROJECTS CONTENTS */

.projectDivs {
  font-size: 9vw;
  border: 1px solid black;
  border-radius: 25px;
  margin-left: auto;
  margin-right: auto;
  width: 78vw;
  margin-bottom: 5px;
}

.projectDivs i {
  text-align: right;
}

.innerProjectDiv {
  display: none;
  text-align: left;
  font-size: 0.5em;
  width: 78vw;
  padding-left: 20px;
  padding-right: 20px;
}

.innerProjectDiv h1 {
  font-size: 0.5em;
}


/* FOOTER  */

.footer {
  background-color: #03032b;
  grid-area: footer;
  text-align: center;
  bottom: 0;
  left: 0;
  right: 0;
  padding: 0px;
  font-size: 15px;
  height: 3vh;
}

@media screen and (max-width: 1000px) {
  .projectDivs {
    font-size: 8vw;
  }
  .homePG {
    padding-top: 20%;
  }
  .homePG img {
    width: 400px;
    height: 400px;
  }
  .footer {
    grid
  }
}

@media screen and (max-width: 750px) {
  .homePG img {
    width: 200px;
    height: 200px;
  }
}
<!DOCTYPE html>
<html>

<head>
  <link rel="stylesheet" href="../style.css">
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
  <title>Brandon | Projects</title>
  <meta name="viewport" content="width=device-width, initial-scale=1">
</head>

<body class="container">
  <section class="section nav">
    <nav class="navLeft">
      <a href="#" class="navTitle">Brandon</a>
    </nav>
    <nav class="navRight">
      <a href="../about.php">ABOUT</a>
      <a href="../projects/#">PROJECTS</a>
      <a href="../contact.php">CONTACT</a>
    </nav>

  </section>

  <section class="section homePG project">
    <h1>Projects</h1>
    <p>
      Lorem ipsum dolor sit amet, consectetur adipiscing elit,
    </p>

    <a onclick="openOverviewDiv(this)" href="javascript:void(0);>
      <div class=" projectDivs ">
        PlaceHolder1
        <i id="icon " class="fa ">&#xf107;</i>
        <div class="innerProjectDiv ">
          <h1>Overview:</h1>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ac ut consequat semper viverra nam libero justo laoreet sit. Bibendum enim facilisis gravida neque convallis a cras semper. Massa
          vitae tortor condimentum lacinia quis vel. Vel elit scelerisque mauris pellentesque pulvinar pellentesque habitant morbi tristique.
        </div>
      </div>
    </a>

    <a onclick="openOverviewDiv(this) " href="javascript:void(0); ">
      <div class="projectDivs ">
        placeholder2
        <i id="icon " class="fa ">&#xf107;</i>
        <div class="innerProjectDiv ">
          <h1>Overview:</h1>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ullamcorper morbi tincidunt ornare massa. Ut venenatis tellus in metus vulputate eu scelerisque felis imperdiet.
        </div>
      </div>
    </a>

    <a onclick="openOverviewDiv(this) " href="javascript:void(0); ">
      <div class="projectDivs ">
        Placeholder3
        <i id="icon " class="fa ">&#xf107;</i>
        <div class="innerProjectDiv ">
          <h1>Overview:</h1>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ac ut consequat semper viverra nam libero justo laoreet sit. Bibendum enim facilisis gravida neque convallis a cras semper. Massa
          vitae tortor condimentum lacinia quis vel. Vel elit scelerisque mauris pellentesque pulvinar pellentesque habitant morbi tristique.
        </div>
      </div>
    </a>
    <a onclick="openOverviewDiv(this) " href="javascript:void(0); ">
      <div class="projectDivs ">
        Placeholder4
        <i id="icon " class="fa ">&#xf107;</i>
        <div class="innerProjectDiv ">
          <h1>Overview:</h1>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ullamcorper morbi tincidunt ornare massa. Ut venenatis tellus in metus vulputate eu scelerisque felis imperdiet.
        </div>
      </div>
    </a>
    <a onclick="openOverviewDiv(this) " href="javascript:void(0); ">
      <div class="projectDivs ">
        Placeholder
        <i id="icon " class="fa ">&#xf107;</i>
        <div class="innerProjectDiv ">
          <h1>Overview:</h1>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ullamcorper morbi tincidunt ornare massa. Ut venenatis tellus in metus vulputate eu scelerisque felis imperdiet.
        </div>
      </div>
    </a>
    <a onclick="openOverviewDiv(this) " href="javascript:void(0); ">
      <div class="projectDivs ">
        Placeholder
        <i id="icon " class="fa ">&#xf107;</i>
        <div class="innerProjectDiv ">
          <h1>Overview:</h1>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ac ut consequat semper viverra nam libero justo laoreet sit. Bibendum enim facilisis gravida neque convallis a cras semper. Massa
          vitae tortor condimentum lacinia quis vel. Vel elit scelerisque mauris pellentesque pulvinar pellentesque habitant morbi tristique.
        </div>
      </div>
    </a>
    <a onclick="openOverviewDiv(this) " href="javascript:void(0); ">
      <div class="projectDivs ">
        Placeholder
        <i id="icon " class="fa ">&#xf107;</i>
        <div class="innerProjectDiv ">
          <h1>Overview:</h1>
          Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ac ut consequat semper viverra nam libero justo laoreet sit. Bibendum enim facilisis gravida neque convallis a cras semper. Massa
          vitae tortor condimentum lacinia quis vel. Vel elit scelerisque mauris pellentesque pulvinar pellentesque habitant morbi tristique.
        </div>
      </div>
    </a>
    <p>

    </p>
  </section>
  <section class="section contentTwo ">
    <p>

    </p>
  </section>
  <section class="section footer ">
    Footer
  </section>

  <script src="function.js "></script>
  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js "></script>
</body>

</html>


from Recent Questions - Stack Overflow https://ift.tt/3qbLoPi
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Hibernate Search - Elasticsearch with JSON manipulation

Spring Elasticsearch Operations