Functionality not working when clicked on iPhones

I'm facing an issue with my dropdown menu that appears when an image is clicked. Below is the relevant HTML code snippet:

   <div class="menu">
     <img  id="menu_img" src="https://res.cloudinary.com/dqn5eqmwt/image/upload/v1493014197/Menu_jwzusk.svg">
     <div id="myDropdown" class="dropdown-content">
        <a id="Edprof">Edit Profile</a>
        <a id="Deprof">Delete Profile</a>
        <a id="Chistory">Check History</a>
        <a id="Bevents">Book Events</a>
        <a id="Getout">Logout</a>
     </div>
  </div>

This CSS controls the styling of the entire menu:

.menu {
display: block;
    position: absolute;
    z-index: 2;
    height:55px; /* 150/640 */
    width:55px;/*150/1536*/
    top: 2.5%;
    right: 10.0208333333%;
    float: right;
    cursor: pointer;
 }
#menu_img{
    width:55px;
    height:55px;
    cursor: pointer;
 }

/* Dropdown button on hover & focus */
.menu:hover, .menu:focus {
    background-color: #3e8e41;
}

/* Dropdown Content (Hidden by Default) */
.dropdown-content {
    display: none;
    position: absolute;
    background-color: #7de88a;
    border: 6px solid #7de88a;
    border-radius: 10px;
    width: 300%;
    right: 0px;
    left: auto;
    box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
    z-index: 2;
    cursor: pointer;
 }

/* Links inside the dropdown */
 .dropdown-content a {
    color: #c43396;
    background-color: #fff3bb;
    font-family: Chewy;
    border: 6px solid #7de88a;
    border-radius: 10px;
    margin-top: 2.5px;
    margin-bottom: 2.5px;
    padding: 12px 16px;
    display: block;
  }

And here's the JS code snippet for handling the onclick event of the image:

$(function(){ 
   $('#menu_img').on('click touch',function() {
   document.getElementById("myDropdown").style="display:block";
 })
});

The issue I'm experiencing is specific to iPhones. The background color changes on click as if it were a hover action, but the dropdown menu does not appear. I have attempted several checks suggested online, such as adding 'cursor:pointer' to menu_img in CSS and testing different event trigger combinations in the JS code. Unfortunately, none of these solutions have worked so far. Any assistance or suggestions would be greatly appreciated. Thank you!

Answer №1

After making some adjustments to your code, I tested it on my server and found that it functions flawlessly across all devices. Here's a handy tip: consider implementing jQuery universally or refraining from using it altogether.

$(document).ready(function(){
   $('#menu_img').click(function(){
     $('#myDropdown').show();
   });
});

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Steps for altering the primary color in PrimeNG__Changing the primary color

What is the most effective way to modify the default primary color for primeNG (saga-blue theme)? Altering --primary-color does not have the desired effect, as elements in node_modules/..../theme.css are styled using the main color hex rather than '-- ...

Vuefire encountering an issue with Vue 3 and throwing a Vue.use error

After setting up a Vue app and importing Vue from the vue module, I encountered an issue: ERROR in src/main.ts:4:5 TS2339: Property 'use' does not exist on type 'typeof import("/data/data/com.termux/files/home/ishankbg.tech/node_modules/vue/ ...

Is it possible to locate a particular value within a nested array?

Help Needed: I'm working with an array that contains a nested array and I need to loop through it to locate a specific value. arr = [['123456','234567'], ['345678']]; specificValue = '123456'; I am looking for ...

Tips for displaying a loading message during an AJAX request?

My AJAX function is set up like this: function update_session(val) { var session_id_to_change=document.getElementById('select_path').value; $.ajax({ type: "GET", url: "/modify_path/", asy ...

Toggle button visibility on ng-repeat item click

Hello everyone, I'm encountering an issue with displaying and hiding buttons in ng-repeat. <div class="row" ng-repeat="item in items"> <button type="button" ng-click="add()">+</button> <button type="button" ng-click="remo ...

Vue.js bootstrap-vue input number has a unique MaxLength feature that sets the

Is there a way to limit the input length for an input field from bootstrap-vue? I tried using maxLength, but it seems that it's not supported based on their documentation. If I remove type="number", the limitation works, but then it won't restric ...

Styles are ineffective on the focus property, although they do work before the focus is applied

I'm having trouble changing the font color of the TextInput in material UI. It seems to change to white when I click away, but then reverts back to a purple-ish color (the default) when I focus on it again. I'm not sure what I'm missing here ...

Utilizing shared components with withStyles and material ui components

I'm currently working on a project using React, TypeScript, and Material UI. Here is the layout I have: <MuiThemeProvider theme={muiTheme}> <My Component/> </MuiThemeProvider> Within my component, the code looks something ...

Problem with Postman's form-data functionality

I am facing an issue with using Postman and body->form-data. The code works perfectly fine when I use express.json parser with body->raw and body->urlencoded, but for some reason it does not work with formData. https://i.sstatic.net/6DuCd.png ht ...

|Webview|Best Practices for Integrating Upload Script

I am currently developing an Android app using WebView and I need to implement a code for uploading on Android. I came across the following code snippet and I want to convert it into JavaScript instead of Java (if possible). It needs to be linked to the up ...

Adding child arrays to a parent array in Angular 8 using push method

Upon filtering the data, the response obtained inside the findChildrens function is as follows: My expectation now is that if the object length of this.newRegion is greater than 1, then merge the children of the second object into the parent object's ...

Facebook news feeds displaying only the most recent 20 posts

I have my feeds stored in JSON format at this URL, but I am only able to see the last 20 posts. How can I retrieve all of my posts using JSON format? ...

What is the best way to display the UID of a Firestore sub-collection publicly while

I have a Firestore database structure set up as shown in image 1. I am looking to allow unauthenticated users of my web application to view the public profiles of plumbers, along with the reviews (image 2) they receive from completed jobs. My main query is ...

What is the best method for sending data from Node.js Express to Ember-Ajax?

I am currently developing a website using Ember with a Node JS Express API, and I am utilizing ember-ajax to communicate with the API. EDIT: Ember version: 1.13 Ember Data: 1.13.15 The issue I am facing is that when Ember makes an AJAX call, it seems t ...

What is the best way to remedy the bottom scroll issue?

I am currently working on a Messaging system and I need the scrollbar to stay fixed at the bottom so that when new data arrives, it automatically scrolls down. How can this be achieved using HTML/CSS? Please ignore any unprofessional formatting in the code ...

We're sorry, the page you are looking for cannot be found. Error 404: Page Not Found

Good day: I am encountering this Django error when attempting to update a "User": Page not found (404) Request Method: GET Request URL: http://127.0.0.1:8000/users/modify/ Using the URLconf defined in APPNAME.urls, Django attempted these URL pa ...

Find the mean of three numbers stored in an array of objects

I am currently working on a school assignment that requires me to develop a function for calculating the average mark of 3 students using an existing object in an array. Below, you can see the array and function that I have been working on as part of this ...

Tips on positioning items with a ChartBar using Chart.js alongside Alerts from Bootstrap 4

Greetings! I am facing a challenge with arranging a bar chart using Chart.js alongside bootstrap 4 alerts. The issue arises in the alignment of elements as depicted in this image: https://i.sstatic.net/4kDSo.png My goal is to position the alerts, located ...

Contrasting Ajax with Jquery-Ajax: Exploring the Variances

Greetings! As someone just starting out with Ajax and jQuery, I've come across quite a few tutorials on both subjects. However, I'm still a bit unsure about the distinction between regular Ajax and jQuery Ajax. Can you provide some clarity on thi ...

Guide to making a slider menu using html, css, and javascript

Just dipping my toes into the world of web development. I'm intrigued by the idea of creating a "slider menu" where users can view and select options by clicking on next or previous buttons (see example image below). While I've got some basic HTM ...