最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

jquery - javascript taking # marker literally - Stack Overflow

matteradmin4PV0评论

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.

Post a comment

comment list (0)

  1. No comments so far