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

129
Views
Javascript document.activeElement is undefined on mobile

So currently this function works on desktop but when I test it on mobile I get "undefined." I checked to see if activeElement is compatible on iPhone safari and it says it works there so I'm currently lost. Any fixes or alternatives?

This is the button that is selected.

<input type='button' id='slogan-button' onclick='changeSlogan()' value='Junior Varsity'>

This is the function to make it work.

<script>
    function changeSlogan() {
        const activeSlogan = document.activeElement.value;
      document.getElementById('slogan-input').value = activeSlogan;
      document.getElementById('slogan-display').innerHTML = activeSlogan;
    }
</script>

This is supposed to allow a slogan to be selected and the value of the slogan is added into a input, I get the equal value of the selected slogan only on desktop.

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

0

The definition of an ActiveElement is an element which is currently in focus. The elements which are focusable vary by platform with no guarantees. For example, MacOS only considers inputs to be focusable. Based on what you wrote, it seems like iOS is the same.

Use the “click” event instead.

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!