• 0

Need help with very simple JavaScript code


Question

I just need a very basic script. I never usually need to use script, which is why I haven't learned how to use it.

I tried having a go with the DOM thingamajigs myself, but I had no luck.

Here is the code that the script will interact with:-

<li class="preview clickable" onclick="this.lastChild.removeAttribute('hidden'); return false;">
    <img src="https://www.example.com/" alt="example" />

    <aside hidden="hidden" class="floatingbox">
        ...
    </aside>
</li>

What I want to do is the following:- When the LI element is clicked, the "hidden" attribute is removed from the ASIDE element. How do I do that?

The current code that I'm using is obviously wrong. I know I could have used getElementById(), but I'd rather not under the circumstances. I was hoping to put the code in a function, so that I could use it with other list items

I'd appreciate any help. :)

Link to comment
Share on other sites

0 answers to this question

Recommended Posts

There have been no answers to this question yet

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.