admin管理员组文章数量:1394076
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("");
});
});
Console output -
foo
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.");
});
});
Console output -
foo
Share
Improve this question
asked Jul 3, 2013 at 20:13
NarabhutNarabhut
8374 gold badges13 silver badges30 bronze badges
0
2 Answers
Reset to default 5Change searchButton
to #searchButton
. It's an ID, so must be prefixed with #
.
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.");
});
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.
本文标签: javascriptRedirect to another webpage in jQuery via button clickStack Overflow
版权声明:本文标题:javascript - Redirect to another webpage in jQuery via button click - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744750399a2623140.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论