DEV Community

Md Abdullah al noor
Md Abdullah al noor

Posted on

why js closest method not find sibling element?

Note: as far as i know that closest() method searches up the DOM tree for the closest element which matches a specified CSS selector.

When i click on margin space between two li element .. it's return null but if i replace margin-bottom: 15px; with padding-bottom... everything is okay...

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay