+ 1
I'm getting value type error on my js script.
I'm trying an animation using the element.style.left=pos+"%" but it's not working. Please what should I do?
22 Réponses
+ 1
Your image has id "cont" but you use "box" in your js ^^
+ 2
Relative units (%) are perfectly valid for positions (left, top, right, bottom) values...
But positionning elements trough these properties requires a positioned element (with the css property 'position' as stated by luis calderón) but not necessarly 'absolute': any valid value appart 'static' (the default value for all elements). The main differences between 'absolute' and 'relative' position mode are:
+ 'absolute' doesn't keep the normal space needed by the element, while 'relative' keep it
+ 'absolute' coordinates (left, top, right, bottom) are relative to the whole document, while 'relative' coordinates are relative to the first positionned ancestor or to the whole document if none
+ 1
Kk, thanks, I've tried most though
+ 1
You may find answer in https://rollbar.com/blog/top-10-javascript-errors/
0
I positioned it well
0
The error is on the line:
element.style.left=pos+"%";
0
... and the error message is???
0
Value type error
0
You must provide more context if you hope for help ^^
Share a code playground project link with your whole script (html/css/js), so we could investigate further ;)
0
Kk
I'd have shared but for the files are on my pc
But I'll rewrite it.
0
You could copy-paste from your pc to the website version of code playground:
https://code.sololearn.com/
0
Ooh, thanks
0
https://code.sololearn.com/WlvItDzIT79w/?ref=app
0
I'm starting to feel the error is because the element is an image
0
I'm starting to feel the error is because the element is an image.
Just copied the major parts into the code bit.
0
The playground is giving the same error
0
The playground is giving the same error
0
I've corrected it, pls check
0
well, it's working fine now :)