Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

106
Views
Can't override CSS directive with caret selector

I have an SVG file (inline in an HTML page) with about 60 buttons.

Each of them has two additional states, each of which has an ID of the form:

<g id="mov0-1"><!-- mouseover state -->
<g id="mod0-1"><!-- mousedown state -->

Initially the mouseover and mousedown states are hidden in CSS:

g[id^='mod'] { display: none; }
g[id^='mov'] { display: none; }

When there is a mouseover, the state should change, using this function:

var obj = document.getElementById('link' + c + '-' + x);
obj.addEventListener('mouseover', mov.bind(null, x, c), false); 
...
function mov(x, c){
  var obj_id = 'mov' + c + '-' + x;
  var obj = document.getElementById(obj_id);
  obj.style.display = 'block';
}

The above function fails. However, if I replace the CSS caret with a list of individual buttons, the function works:

g#mov1-0{display:none;}
g#mod1-0{display:none;}

Why is this happening?

Is there a way I can keep my elegant two-line solution that hides 120 buttons instead of having to list them all separately?

N.B. the SVG's are generated automatically by Adobe Illustrator, and I can't use CSS classes.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

So it was a boneheaded mistake.

The parent objects also had ID's that began with mov and mot, so when I hid the unused buttons, I also hid their parent containers.

Lesson 1: be careful with wildcards.

Lesson 2: when something breaks, don't assume it's because of some elaborate technical thing instead of a stupid error.

Lesson 3: build a simple test case to reproduce the problem.

Renaming the parent containers (Illustrator layers) fixed the problem.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!