开发者

jq div display script webkit issues

$(document).ready(function() {
    $('#chekboxes  a').click(function(e) {
        $('.visible').removeClass('visible').addClass('invisible');
        var thediv = $(this).attr('href');
        $(thediv).removeClass('invisible').addClass('visible');
    })
});

This simple bit of jq works in FF and not in 开发者_JAVA技巧Chrome and Safari.

Despite googling widely, I cannot tell whether there's a way to make it work in Safari and Chrome or not.

Does anyone know a fix or what is wrong ?

html: html-pastie

Thanks, Tom


Note: This answer is as of this revision of the question which doesn't offer any HTML or CSS to work with. If something is subsequently clarified after I've left (it's night time here in the UK), the below may become outdated.


Fundamentally, that code seems to work if we make various assumptions about your markup and intent.

This is a total stab in the dark, but: You're using the href of an anchor directly as your selector for which div to make visible. Have you inspected the actual value you get back on Safari and Chrome? Could it be that it's a complete URL rather than (say) just a #foo or similar? Note that both Safari and Chrome have built-in dev tools (you may need to enable them in Options) that will let you step through that code and inspect values easily in a debugger.

Now, my specific example of the href value above (expecting the anchor only and getting the whole thing) isn't it according to this quick test, but the fundamental point holds: Look at the value you're getting and step through the code, on both (say) Firefox (using Firebug) and on Chrome or Safari using Dev Tools.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜