0

I'm having a problems, everytime I click my btn_register the tab goes back to Login. Why is this?

Here's my JAVASCRIPT Code:

$(function() {
        $("input:submit").button();
        $("#tabs").tabs();
    });

Here's my HTML Code:

<section id="tabs">
<ul>
    <li><a href="#login">Login</a></li>
    <li><a href="#register">Register</a></li>
</ul>
<article id="login">
    <p>
        <form>
            <input type="submit" id="btn_login">
        </form>
    </p>
</article>
<article id="register">
        <form>
            <input type="submit" id="btn_register">
        </form>
    </p>
</article>

4

3 に答える 3

1

It's because JQuery doesn't know which input:submit you are referring to. Check this out for help

于 2012-09-22T01:47:57.917 に答える
1

depends what you're trying to do, but it is because I am assuming this is on the login page? I believe by default, when you have a input type submit, it will try to send the form to the current page. If it is not a form, and just a button, I recommend you use the button tag instead:

<button id='btn_register'>Register</button>

On some browsers, the button tag will not do anything, but it may still refresh the page. to stop this behavior, append this to your code:

$('#btn_register').on('click',function(e) {
  e.preventDefault();
  //do whatever you want to here        
});

if the register button is just suppose to be a link that will go to another page, I suggest using the anchor tag instead.

于 2012-09-22T01:51:05.893 に答える
0
        $("#btn_login").button();
    $("#btn_register").button();

コードをこれに変更します。そしてそれは動作します

于 2012-09-22T01:54:54.347 に答える