我有一个简单的脚本来隐藏和显示某些按钮,但javascript不会运行,直到重新加载页面.如果用户点击该链接,我怎样才能让它运行?例如,在用户第一次链接到页面时,页面已经隐藏了某些div.
var array = [".section-1", ".section-2", ".section-3", ".section-4", ".section-5"];
var cnt = 0;
$(function() {
for(var i = 0; i < 5; i++) {
$(array[i]).hide();
}
$(array[cnt]).show();
$(".previous").hide();
$(".next").click(function () {
if(cnt < 4){
$(array[cnt]).hide();
cnt++;
$(array[cnt]).show();
}
if (cnt == 4) {
$(".next").hide();
}
if(cnt > 0) {
$(".previous").show();
}
});
$(".previous").click(function (){
if(cnt > 0) {
$(array[cnt]).hide();
cnt--;
$(array[cnt]).show();
}
if(cnt < 4){
$(".next").show();
}
if(cnt == 0){
$(".previous").hide();
}
});
});
Run Code Online (Sandbox Code Playgroud)
这是清单文件.
// This is a manifest …Run Code Online (Sandbox Code Playgroud) 我正在使用设计宝石,我在让我的应用程序在heroku上工作时遇到了问题.我不确定这是数据库的问题还是设计自己.在安装设备之前它工作正常.我在下面放了一个heroku日志.
2014-03-03T05:01:41.875781+00:00 app[web.1]: => Ctrl-C to shutdown server
2014-03-03T05:01:41.859124+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/railties-4.0.2/lib/rails/commands/server.rb:48:in `app'
2014-03-03T05:01:41.875781+00:00 app[web.1]: => Booting WEBrick
2014-03-03T05:01:41.875781+00:00 app[web.1]: => Rails 4.0.2 application starting in production on http://0.0.0.0:24518
2014-03-03T05:01:41.859124+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/builder.rb:49:in `eval'
2014-03-03T05:01:41.875781+00:00 app[web.1]: => Run `rails server -h` for more startup options
2014-03-03T05:01:41.875781+00:00 app[web.1]: Exiting
2014-03-03T05:01:41.859124+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
2014-03-03T05:01:41.859124+00:00 app[web.1]: from /app/vendor/bundle/ruby/2.0.0/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
2014-03-03T05:01:41.859299+00:00 app[web.1]: from bin/rails:4:in `require'
2014-03-03T05:01:43.043928+00:00 heroku[web.1]: Process exited with status 1
2014-03-03T05:01:43.048168+00:00 heroku[web.1]: State changed from starting to crashed
2014-03-03T05:01:47.110760+00:00 heroku[router]: …Run Code Online (Sandbox Code Playgroud)