Reputation: 837
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
Upvotes: 0
Views: 3381
Reputation: 123739
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.
Upvotes: 3
Reputation: 5010
Change searchButton
to #searchButton
. It's an ID, so must be prefixed with #
.
Upvotes: 5