JavaScript error: Uncaught SyntaxError: missing ) after argument list


i dont know were to ask general jquery questions so ill do it here

<script src="//"></script>
<img src="">
  $('div').text(event.pageX + " " + event.pageY);
  const mouseX = event.pageX
  const mouseY = event.pageY
$('img').css('margin' 'absolute '+'mouseX'+'px');

i am trying tho get the img element to follow the mouse’s x using $(jquery).pageX but i am getting this error.
the problem seems to be in the $(‘img’.css) line


looking at the css documentation:

setting multiply properties takes a dictionary (from documentation):

.css({ "background-color": "#ffe", "border-left": "5px solid #ccc" }) 

if the background-color is then stored in a variable, you can simply do:

.css({ "background-color": backgroundColorVariable, "border-left": "5px solid #ccc" }) 

nice and simple.

not sure what you currently do, margin is a property, absolute is a value, but of position


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.