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

85
Vistas
I want to add a style or class using a script
  1. I want to give the script to add "Class=C" to "Class=B" when "Class=A" has "position: absolute" style.

Or

  1. I want to give the script so that when "Class=A" has the style "position: absolute", it adds the style "bottom: 0px" to "Class=B".

I'm not familiar with scripts.

I've tried the code attached below, but it doesn't work.

How do I give a script like 01 or 02?

please help..!

※I used a translator because I couldn't speak English. That is why my words may not be natural. Please understand.

$(function(){ 
    if ($('.A').css('position' == 'absolute')) {
        $('.B').addClass('C');
    }
    else {
        $('.B').removeClass('C');
    }
});

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

this should work as you expect

$(document).bind('DOMSubtreeModified', function () {
    if ($('.A').css('position') == 'absolute') {
        $('.B').addClass('C');
    }
    else {
        $('.B').removeClass('C');
    }
});

Edit 1

The above code will run whenever the DOM structure changes. The delay is caused by something on your side, after the dom changes it will call the above function.

Edit 2

You could try this, but it may not work

$(document).bind('change', function () {
    if ($('.A').css('position') == 'absolute') {
        $('.B').addClass('C');
    }
    else {
        $('.B').removeClass('C');
    }
});
about 4 years ago · Juan Pablo Isaza Denunciar

0

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"> 
<title></title> 
<script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js">
</script>
<style>
    .A {
        position:absolute
    }   
    .C {
        color:red
    }
</style>
<script>
$(document).ready(function(){
    if ($('.A').css('position') == 'absolute') {
        $('.B').addClass('C');
    }
    else {
        $('.B').removeClass('C');
    }
});
</script>
</head>
<body>
<p class="A">如果你点我</p>
<p class="B">继续点我!</p>
</body>
</html>
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