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

249
Views
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 answers
Answer question

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 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!