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

155
Vistas
Javascript targeting specific element and removing characters from it

I have a really complicated looking path that I want to target first of all I don't what to use to get the path so javascript can target it, I have

  1. Selector
  2. Js Path
  3. Xpath
  4. Full Xpath

Then I want to remove a text from it, namely the word 'by'

Here's the code I frankenstiened together from all the things said by many other users:

$('/html/body/div[1]/div[3]/div/div[2]/div/div[1]/div/div/div[1]/section/div[2]/div[1]/div[2]/div[2]/div/div');
{
$(this).html( $(this).html().replace("by",""); 
});

If you don't understand the code I tried to make, I first of all:

  1. tried to target a path with Xpath and put it as a variable
  2. I used this.html to target it (no idea why i used 2 but that's what one of the answers from this site)
  3. Used .replace to attempt to replace the words "by Mishaal; Masked Man"

This did not work and gave me the error: "Uncaught SyntaxError: missing ) after argument list"

image

Help appreciated, thank you.

about 4 years ago · Santiago Trujillo
2 Respuestas
Responde la pregunta

0

The example is not very clearly explained, I also don't know what specifically other users advised, the specific case is missing but from guesses I can deduce that you are using jquery. Try to pull xpath to a variable but not as a jquery object $(...) but as a regular string and only use .replace() on it.

const path = '/html/body/div[1]/div[3]/div/div[2]/div/div[1]/div/div/div[1]/section/div[2]/div[1]/div[2]/div[2]/div/div';

const formatted = path.replace('be', '');
about 4 years ago · Santiago Trujillo Denunciar

0

Thank you very much everyone, I frankensteined everything I saw on webpages and concluded with this:

var element = document.evaluate( '/html/body/div[1]/div[3]/div/div[2]/div/div[1]/div/div/div[1]/section/div[2]/div[1]/div[2]/div[2]/div/div' ,document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null ).singleNodeValue;

  element.textContent = element.textContent.replace('by ','')

it looks messy but it works.

about 4 years ago · Santiago Trujillo 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