Answer the question
In order to leave comments, you need to log in
Similar to cycle tag in Handlebars?
Hello! Please tell me how to organize the following behavior {{#each}}
:
<div class="row">
<div class="col-sm-4">...</div>
<div class="col-sm-4">...</div>
<div class="col-sm-4">...</div>
</div>
<div class="row">
<div class="col-sm-4">...</div>
<div class="col-sm-4">...</div>
<div class="col-sm-4">...</div>
</div>
// ...
{% cycle 'row1' 'row2' %}
Answer the question
In order to leave comments, you need to log in
Your script is executed before jQuery is initialized. wrap it in$(function() { /* здесь код */ });
$(function() {
var top = 0, bottom = 0, left = 0, right = 0;
$("#up").click(function() {
top += 2;
$("#player").css("bottom", top);
});
});
Everything moves, but on the first click, the value of bottom is set to zero.
Checked here:
https://jsfiddle.net/dn5x3auc/
Because your variable name is top and it is global. But there can't be a global variable with that name, the place is already taken . So when you do top += 2
, you are not working with a number at all. Change the name of the variable, or run your code in a scope other than the global scope, or make your top a property of some object, or...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question