0

I'm not sure why this isn't working? I've tried a couple methods and looked around, but none of the examples work for me. My code:

HTML

<div id='SearchBar'>

    <form id='SearchBar'>

        <input placeholder='Search' id='SearchBar'></input>

    </form>

</div>

CSS

#SearchBar{
                background:#ffffff;
                width:224px;
                height:32px;
                float:right;
            }

                form#SearchBar {
                    width:100%;
                    height:100%;
                }

                    input#SearchBar {   
                        font-size:16px;
                        border:none;
                        width:208px;
                        height:32px;
                        padding:0 8px;
                    }

                        input#SearchBar:focus{
                            outline-color:#2c5aa0;
                        }

jQuery

$('input#SearchBar').keypress(function(event) {

    if (event.which == 13) {

              window.location = list.html; //or submit or do whatever

    }

});

Any help is appreciated. Where am I going wrong?

4

1 回答 1

0

Listen to keyup event and you are missing quotation marks for list.html, list object is undefined so it doesn't have html property!

$(function(){
    $('#SearchBar').keyup(function(event) {
        if (event.which == 13) {
            window.location.href = 'list.html'; 
        }
    });
})
于 2013-02-24T03:38:53.017 回答