-2

I have FontAwesome icons with class='className'.

<i class="className fas fa-circle"></i>
<i class="className fas fa-circle"></i>

and the below jQuery script.

$(document).on('click', '.className', function () {
    console.log('working');
});

It works fine on desktop but is unresponsive on my iPhone SE Safari browser.

edit: added closing tags, just forgot to add them here, I'm using i, as that is what the FontAwsome site uses?

Ari
  • 5,301
  • 8
  • 46
  • 120

3 Answers3

1

Don't bind to the document, bind to a wrapper of the icons. Not sure why you used the "italic" or stand off element so I changed to a span:

https://developer.mozilla.org/en-US/docs/Web/HTML/Element/i

$("#myicons").on('click', '.className', function() {
  console.log('working');
});
<div id="myicons">
  <span class="className fas fa-circle" />
  <span class="className fas fa-circle" />
</div>
Mark Schultheiss
  • 32,614
  • 12
  • 69
  • 100
0

Would test with the following:

$(function() {
  $(document).on('click', '.className', function() {
    console.log('working');
  });
});
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<i class="className fas fa-circle"></i>
<i class="className fas fa-circle"></i>

There should be no issue with testing on Mobile versus Desktop. Unless you have some conditional statement that loads different Libraries for Mobile.

If you need further help, please a Minimal, Complete, and Verifiable example.

Twisty
  • 30,304
  • 2
  • 26
  • 45
-1

I had jQuery UI loaded, no longer using, removed it and now pressing the tags works.

I assume if I left jQuery UI and wrapped the tags with a tag it may have worked?

in any case I also used old mates method of selecting the wrapper, not the document.

Ari
  • 5,301
  • 8
  • 46
  • 120