Jump to content
iwato

Javascript Event Listener on CSS Pseudo Selector

Recommended Posts

I recently tried, on my own machine, to implement three code segments (HTML, CSS, and Javascript) that I found on Fiddler. What I thought would be a quick aside turned into well over an hour's worth of failed experimentation.  Can you find anything wrong with the code that I was not able (click on Fiddler above).

I do not like to leave unfinished work in defeat, but must move on.  Matomo is just plain exciting!

Roddy

Share this post


Link to post
Share on other sites

I just tested the code in three browsers and it is working correctly, even in Internet Explorer. What is the issue?

Share this post


Link to post
Share on other sites

I have no trouble making the code work in the Fiddle context either.  It is when I take it out of context that it fails.

Roddy

 

Share this post


Link to post
Share on other sites

I can't help you if you don't show me the code in a context where it doesn't work.

  • Thanks 1

Share this post


Link to post
Share on other sites

I realize this, but it is fairly complex.  With your prompting I just eliminated the context and was able to make it work.  For the moment this will have to be satisfactory.

Thanks!

Roddy

Share this post


Link to post
Share on other sites

ADDENDUM:  For what it is worth, I discovered the problem by working backward from a blank HTML file.  The appearance of any addition <h3> element disrupts the procedure. 

QUESTION:  How would you explain this?  What would cause the script to fail in the presence of another <h3> tag?

Roddy

Edited by iwato

Share this post


Link to post
Share on other sites

The Javascript only targets the first h3 element on the page, it's pretty obvious from the code. I would hope you're not just copying and pasting code without knowing what it does.

Share this post


Link to post
Share on other sites

That might be the reason that I ask.  Javascript is still a little foreign to me.  I work much better with PHP.

Roddy

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×