0

I'm currently facing a problem where my on click function doesnt trigger in safari but does work in other browsers.

I have two span elements which should work as buttons

HTML:

  <span class="firstLink" onclick=""><a>addClick + </a></span>
  <span class="secondLink" onclick=""><a>removeClick -</a></span>

jQuery:

$('body').on('click', 'span.firstLink', function() {
    currentClick++;
    clickPerformer(currentClick);
});

$('body').on('click', 'span.secondLink', function() {
    currentClick--;
    clickPerformer(currentClick);
});

Here's clickPerformer function:

function clickPerformer(i) {
    var obj = {
        show: function() {
            alert(i);
        }
    };
    obj.show();
}

Previous code is all inside

$( function() {
    // here
});

When I call clickPerformer when page loads, it works. But not when I click on those two 'buttons'.

When I put

alert('blah blah...')

inside

$().on('click')

it wont work aswell.

Any ideas what might cause the problem? All help appreciated!

Roland Ruul
  • 1,172
  • 8
  • 15
  • 1
    http://stackoverflow.com/questions/12925153/jquery-click-works-on-every-browser-but-safari – Rino Raj Jan 07 '16 at 10:18
  • This is not a good way of forming your HTML using `addClick + ` would be much better with `event.preventDefault();` in the click function. You will also need to add `event` to the function params like so `$('body').on('click', 'span.secondLink', function(event) {...}` – lukehillonline Jan 07 '16 at 10:26

0 Answers0