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

233
Views
How to implement click events and links in webpage on Android Mobile Device

I have an html page with two buttons which swap the visibility of associated divs. The click event on the buttons work on desktop but not on my Android mobile. How do I get this to work on both desktop and mobile? Also the href link does not work on mobile.

html code extract

<div class="content" id="calculator">

    <button id="details" class="tab-button">Details</button>
    <button id="result" class="tab-button">Result</button>

    <div id="details-content">
      Details
    </div>

   <div id="result-content" class="chart-container" onresize="responsiveFonts()">
        <canvas id="StackedbarChartCanvas"></canvas> 
   </div>

</div> 

<p class="center-text">Please read the <a class="link" href="disclaimer.php">Disclaimer</a></p>

css


.tab-button{
  border-radius: 5px;
  border: 1px solid #000;
  padding: 5px 10px;
  background: yellow;
  font-size: 1em;
  cursor: pointer;
}

#details-content {
  display: block;
}

#result-content {
  display: none;
}

Javascript code

$(document).ready(function() {
    $("#result").on("click", function(evt) {
      displayResultContent();
    });

    $(document).on('click', '#details', function() {
      displayDetails();
    });
  });

function displayResultContent() {
  document.getElementById("details-content").style.display="none";
  document.getElementById("result-content").style.display="block";
  calculateResult();
}

function displayDetails() {
 document.getElementById("details-content").style.display="block";
 document.getElementById("result-content").style.display="none";
}
about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You have half vanilla javascript code and half jquery . Not all mobile devices work adequately with a pure javascript, almost everything works with jquery.

$(document).ready(function() {
    $('#result').click(function() {
        $('#details-content').hide();
        $('#result-content').show();
        calculateResult();
    });

    $('#details').click(function() {
        $('#details-content').show();
        $('#result-content').hide();
    });

    $(window).resize(function() {
        responsiveFonts();
    });
});

function calculateResult(){
   alert('this function -> "calculateResult"'); /* for example... */
}

function responsiveFonts(){
   console.log('hello foom funcion "responsiveFonts"');/* for example... */
}
.tab-button{
  border-radius: 5px;
  border: 1px solid #000;
  padding: 5px 10px;
  background: yellow;
  font-size: 1em;
  cursor: pointer;
}

#details-content {
  display: block;
}

#result-content {
  display: none;
}
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

<div class="content" id="calculator">

    <button id="details" class="tab-button">Details</button>
    <button id="result" class="tab-button">Result</button>

    <div id="details-content">
      Details
    </div>

   <div id="result-content" class="chart-container">
        <canvas id="StackedbarChartCanvas"></canvas>
   </div>

</div>

<p class="center-text">Please read the <a class="link" href="/disclaimer.php">Disclaimer</a></p>

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