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

255
Vistas
Firefox extension - how to click button by Class and Title?

I have a Firefox extension that clicks something, and the code responsible for the actual click is this:

function xxBtn(){
  var btn = document.querySelector('button.ooo-qqq-vvv')
  if( !btn ){ return }
  btn.click()
}

The code it's clicking on is this:

<button class="ooo-qqq-vvv zzz-ttt" aria-label="One (k)" title="One (p)">

How can I make it so that it only clicks if BOTH the "class" and "title" elements are true?

So let's say we have these three on the page:

<button class="ooo-qqq-vvv zzz-ttt" aria-label="One (k)" title="One (p)">
<button class="ooo-qqq-vvv zzz-ttt" aria-label="One (k)" title="Two (p)">
<button class="ooo-qqq-vvv zzz-ttt" aria-label="One (k)" title="Three (p)">

I only want the click to happen on the first one. So I need both the class and title to be true for a click to occur. The way it works right now is it clicks by class, and it will click all of them.

Thanks

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

0

Try something like this:

 var btn = document.querySelector('.ooo-qqq-vvv.zzz-ttt[title="Two (p)"]')

For further reference you can read the MDN and W3Schools documentation.

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