jquery - change style of mutiple div id's -


i need changing every img element id "playersprite". on keypress event, elements playersprite id need subtract 16px top style.

code:

if (evt.keycode == 38) {     document.getelementbyid("playersprite")style.top -16px; } 

html:

<img src="images/test.png" id="playersprite" style="position: absolute; top: 136px; left: -176px;"> <img src="images/test2.png" id="playersprite" style="position: absolute; top: 136px; left: -176px;"> 

how working?

use jquery. should work.

if (evt.keycode == 38) {     $("img").css("top","-16px"); } 

edit: cant have multiple images same id, if need selection of images, give them same class , change "img" ".class"


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -