Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

107
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda