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

136
Views
cambiar el tamaño del pie de página por id

Estoy tratando de ejecutar una función que cambia el tamaño del margen superior según lo que se muestra. Sin embargo, no parece estar funcionando?

 <body onload="changeFooter()"> <script> const heading = document.getElementById('verify'); const footer = document.getElementById('footer') function changeFooter () { if (heading == true){ footer.style.marginTop = "200px" } }

también probé esto

 function changeFooter () { if (heading.match('Verify')){ footer.style.marginTop = "200px" } } </script> <h1 id="verify" class="verifyheading">Verify Identity</h1>

Gracias

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

0

document.getElementById devuelve el elemento (si existe) o nulo, no booleano (verdadero/falso).

Simplemente puede hacer if(heading) { ... } como su condición.

Aquí hay un fragmento basado en su código: https://codepen.io/29b6/pen/XWZVqWx

about 4 years ago · Juan Pablo Isaza Report

0

Deje que coloque el código de línea de <h1> antes de su etiqueta de secuencia de script , heading se anulará si aún no se define:

 <body onload="changeFooter()"> <h1 id="verify" class="verifyheading">Verify Identity</h1> <div id="footer">Footer with marginTop</div> <script> const heading = document.getElementById('verify'); const footer = document.getElementById('footer') function changeFooter () { if (heading){ footer.style.marginTop = "200px" } } </script>

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!