php - Adding amount to background-position on click (jQuery) -


I am very new to js and jquery, please stand by me.

I want to change the background position and # 1 when adding # button to # 1, clicking on # button 1 takes 1% at # 1 and ## while clicking on button 2

How do I get it in jQuery?

Hey, Bonus Question: These are going to be dynamically generated via PHP.

Like this:

  $ i = 1 while ($ i & lt; = 5) Is it possible to use php in JS-scripts? : $ Div [$ i] = 'div' $ I; $ Left button [$ i] = 'left left' $ I; $ Rightbath [$ i] = 'rightboot' $ I; $ I ++; Endwhile;  

Or how to learn a loop in JS;)

Edit: Follow the questions:

How can I update a text field with this value as I click on the button? And how can I modify it if I also want to add button above / below? Thanks a lot!

Thanks in advance! -Simon

like this:

  function makeClicker (index) {$ ('# Leftbutton' + index) .click (function () {var bPos = $ ('# div' + index) .css ('background-position'); bPos = bPos.replace (/% / g, '') .split (''); bPos = (-1 + parseInt (bPos [0], 0) + '%' + bPos [1] + '%'; $ ('# div' + index). CSS ('background-position', BPOS);}); $ ('# Rightbutton' + index) .click (function () {var bPos = $ ('# div' + index). CSS ('background-condition'); bPos = bPos.replace (/% / g, ' ') .split (' '); bPos = (1 + parseInt (bPos [0], 0) +'% '+ bPos [1] +'% '; $ (' # div '+ index). CSS ( 'Background-position', BPOS);}); } (Var i = 1; i & lt; = 5; i ++) makeClicker (i); 


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -