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

285
Views
¿Cómo puedo cambiar el color del borde de un nodo desde su XPath?

Tengo el XPath de un elemento (por ejemplo, //html/body/div[1]/div[2] ). Quiero buscar el elemento y cambiar el color del borde.

Puedo buscar el nodo usando

 document.evaluate(xPath, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE).singleNodeValue

Pero no sé qué hacer a continuación...

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

0

No está muy lejos de eso: dado que tiene el nodo del código provisto, solo tiene que asignar agregar el estilo. Una forma es usar JavaScript para agregar los estilos en línea, por ejemplo:

 // Select the node var myDiv = document.evaluate('//html/body/div[1]/div[2]', document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue; //Add the style in-line myDiv.style.border = "1px solid red"; // Or you can define a CSS class and add it that way // myDiv.classList.add("my-class-with-border");

Ejemplo de trabajo: https://codepen.io/scarabaeus/pen/wvPqMPK

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!