convert javascript code to jQuery -
i want change javascript code jquery code, reason when i'm targeting id it's not working.
javascript code:
scroll(xpos, ypos) { document.getelementbyid('content_section').scrolltop=xpos; } jquery code (i wrote):
scroll(xpos, ypos) { $('#content_section').scrolltop(); } what did wrong? , need work on internet explorer.
for answers had, tried add scrolltop(xpos); , didn't work still, put in mind ie issues.
$('#content_section').scrolltop(xpos); because scrolltop() takes argument scroll target.
more detail
.scrolltop() without argument works getter method, means
$('#content_section').scrolltop(); // without argument will give current scroll position of #content_section.
but argument acts setter method means
$('#content_section').scrolltop(xpos); // argument will set #content_section position passed argument.
according edit
function scroll(xpos, ypos) { // need set argument xpos $('#content_section').scrolltop(xpos); } may can try
function scroll() { $('#content_section').scrollto({left: xpos, top: ypox}, 400); }
Comments
Post a Comment