Communities

Writing
Writing
Codidact Meta
Codidact Meta
The Great Outdoors
The Great Outdoors
Photography & Video
Photography & Video
Scientific Speculation
Scientific Speculation
Cooking
Cooking
Electrical Engineering
Electrical Engineering
Judaism
Judaism
Languages & Linguistics
Languages & Linguistics
Software Development
Software Development
Mathematics
Mathematics
Christianity
Christianity
Code Golf
Code Golf
Music
Music
Physics
Physics
Linux Systems
Linux Systems
Power Users
Power Users
Tabletop RPGs
Tabletop RPGs
Community Proposals
Community Proposals
tag:snake search within a tag
answers:0 unanswered questions
user:xxxx search by author id
score:0.5 posts with 0.5+ score
"snake oil" exact phrase
votes:4 posts with 4+ votes
created:<1w created < 1 week ago
post_type:xxxx type of post
Search help
Notifications
Mark all as read See all your notifications »
Q&A

Welcome to Software Development on Codidact!

Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.

Comments on queryselector for all does not select the specified css selectory

Post

queryselector for all does not select the specified css selectory [closed]

+0
−4

Closed as not constructive by Alexei‭ on Jan 11, 2023 at 08:50

This question cannot be answered in a way that is helpful to anyone. It's not possible to learn something from possible answers, except for the solution for the specific problem of the asker.

This question was closed; new answers can no longer be added. Users with the reopen privilege may vote to reopen this question if it has been improved or closed incorrectly.

I tried using query selector but it does not work heres my HTML code:

<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <title>JS + CSS Clock</title>
  <link rel="stylesheet" href="styles.css">
</head>
<body>


    <div class="clock">
      <div class="clock-face">
        <div class="hour-hand"></div>
        <div class="min-hand"></div>
        <div class="second-hand"></div>
      </div>
    </div>
    <script src="index.js"></script>

</body>
</html>

Heres my css code:

html {
    background: #018DED url(https://unsplash.it/1500/1000?image=881&blur=5);
    background-size: cover;
    font-family: 'helvetica neue';
    text-align: center;
    font-size: 10px;
  }

  body {
    margin: 0;
    font-size: 2rem;
    display: flex;
    flex: 1;
    min-height: 100vh;
    align-items: center;
  }
  .second-hand{
    width: 50%;
    height: 6px;
    background: black;
    position: absolute;
    top: 50%;
    transform-origin:100% ;
    border-radius: 20px;
    transition: all 0.5s;
    transform: rotate(90deg);

  }

Heres my .js file:

const secondHand=document.querySelector('.second-hand');
function setDate(){
    const now= new Date();
    const seconds=now.getSeconds;
    const secDEG=6*seconds;
    secondHand.style.transform =`rotate(${secDEG}deg)`;
    const minutes=now.getMinutes;
    const hours=now.getHours;
}
setInterval(setDate, 1000);

The problem is that the secondHand returns null and the element doesnt get selected.

History
Why does this post require attention from curators or moderators?
You might want to add some details to your flag.
Why should this post be closed?

3 comment threads

You're not calling the getter methods (2 comments)
Closure (1 comment)
Are you sure that's the problem? (1 comment)
Are you sure that's the problem?
Moshi‭ wrote almost 2 years ago

Try setting a console.log and seeing what the value of secondHand is

Also, getSeconds etc. is a function.

Skipping 1 deleted comment.