A
A
Alexander Timofeev2015-11-05 16:58:57
JavaScript
Alexander Timofeev, 2015-11-05 16:58:57

How to make it so that when clicking on one element, the value of some parameter of the other changes, i.e. added, for example, every time?

It is necessary that when clicking on .arrow-next-timelineeach time, some value is added to the parameter lefty .overflow-timeline>div
Wrote something like this, but something is not right ...

$('.arrow-next-timeline').on('click', function(){
    var i = $('.overflow-timeline>div').css('left');
    i += 100;
    $('.overflow-timeline>div').css('left', i + 'px'); 
});

Here is a simplified example (working): jsfiddle.net/timofeev/tgb7bb7g/2
And here is an attempt to do what is written above: jsfiddle.net/timofeev/tgb7bb7g/3

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Ineshin, 2015-11-05
@aldtimofeev

var left = 0;

$('.first').on('click', function () {
    left++;
    $('.second')[0].style.left = left + 'px';
});

Y
Yuri, 2015-11-05
@kapitan7830

Try like this

var i = parseInt($('.overflow-timeline>div').css('left'));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question