javascript - How can I add 10px to a div's left coordinate? -
i wondering how can add 10px div's current left position. here code:
<div id="ok" style="width:56px; height:56px; background:blue; color:white; position:absolute; top:5px; left:5px; z-index:8;">hello</div>
i want add 10px left of position absolute div using javascript, code this. here code:
<div id="ok" style="width:56px; height:56px; background:blue; color:white; position:absolute; top:5px; left:15px; z-index:8;">hello</div>
how can add 10 left of div using javascript?
in jquery rather easy using callback function second argument of css
method:
$('#ok').css('left', function(i, val) { return parseint(val, 10) + 10; });
Comments
Post a Comment