1

I have a few location attrs on my website for a few dynamic drop downs and clickable divs. While testing I saw that they are not working on any ipads or iphones. Is there a reason for this?

They look like this

$('.storyClick').click(function () {
    var context = $(this).closest('.storyClick'),
        story_id = context.find('.story_id').val();
    $(location).attr('href', '/chapters/' + story_id)
});

The updated code? Sure...

$('.storyClick').click(function () {
  var context = $(this).closest('.storyClick'),
  story_id = context.find('.story_id').val();
  location.href = '/chapters/' + story_id;
});
4

1 回答 1

3

Why are you making a jQuery object out of that?

location.href = '/chapters/' + story_id;

DOM nodes are the only things that should be wrapped in a jQuery object. (Well, ideally, nothing would be, but here we are.)

And you apparently need to handle two events using .on('click touchstart', …), because it’s not a link.

于 2013-10-19T21:03:29.070 回答