0

I'm using Jade and my HTML template looks something like this

.container
        .row
          form
            .span3.input-append(style='margin-top: 30%; margin-left: 30%;')
              input#main_search.span2(style='height: 26px; width: 400px;', type='text', id='searchBox' )
              input.btn.btn-large.btn-primary(type='button', value='search', id='searchButton')
include partials/scripts

And my scripts.jade includes a bunch of Javascript functions including

$(document).ready(function() {
    console.log('foo');
    $("searchButton").click(function() {
        console.log('sup');
            window.location.replace("http://stackoverflow.com");
    });
});

Console output -

foo
0

2 Answers 2

5

Change searchButton to #searchButton. It's an ID, so must be prefixed with #.

Sign up to request clarification or add additional context in comments.

Comments

3

You are missing # in the id selector. it should be #searchButton instead of searchButton

 $("#searchButton").click(function() {
        console.log('sup');
            window.location.replace("http://stackoverflow.com");
    });

Also not that even you have incorrect selector $("searchButton") which does not find any elements jquery will not throw any error while registering the click handler on them unlike document.getElementById where the result will be undefined and accessing the properties will throw an error.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.