最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

jquery - javascript taking # marker literally - Stack Overflow

programmeradmin1浏览0评论

I have some code on some of my links

<a class="nav_bu" onclick="switchType('all'); return false;" href="#">

when I click on them, I get fowarded to mydomain/# (404 error..).

How can I get the function activated, rather then the href link.

P.S. I have mod_rewrite running, is this screwing things up? Here are the rules that effect the root directory:

RewriteRule ^home/$ home.php [L]
RewriteRule ^inbox/$ inbox/inbox.php [L]

I have some code on some of my links

<a class="nav_bu" onclick="switchType('all'); return false;" href="#">

when I click on them, I get fowarded to mydomain./# (404 error..).

How can I get the function activated, rather then the href link.

P.S. I have mod_rewrite running, is this screwing things up? Here are the rules that effect the root directory:

RewriteRule ^home/$ home.php [L]
RewriteRule ^inbox/$ inbox/inbox.php [L]
Share Improve this question asked Aug 13, 2009 at 11:30 fsdkfjfsdkfj
Add a ment  | 

3 Answers 3

Reset to default 16

I think you have an error in the switchType('all') function. That is why the browser does not get to return false; and uses the default action to redirect you to href.

use button instead of link

First of all, you state, based on your tags, that you are using jQuery. Why would you be using inline javascript listeners then?

Try this:

$(function() {
    $('.nav_bu').click(function() {
        switchType($(this).attr('rel'));
        return false;
    });
});

If this is your HTML:

<a class="nav_bu" rel="all" href="#">Blah Blah</a>

But, yeah... like people are saying, you probably have a problem with your switchType function. Run the site in Firefox with Firebug installed and it should tell your right where you problem is.

发布评论

评论列表(0)

  1. 暂无评论