Using Javascript we can change css value. Here I have written how to change the value of padding top, padding bottom, padding left, padding right differently.
var ab = 20;
//To change Padding-top value write
document.getElementById("div_Id").style.paddingTop = ab.toString()+"px"
//To change Padding-left value write
document.getElementById("div_Id").style.paddingLeft = ab.toString()+"px"
//To change Padding-right value write
document.getElementById("div_Id").style.paddingRight = ab.toString()+"px"
//To change Padding-bottom value write
document.getElementById("div_Id").style.paddingBottom = ab.toString()+"px"
Magento Tutorial, Magneto modules, Magento Banckend, Magento admin, Magento Frontend, Magento Interview Question, Jquery, CSS, Javascript, PHP, XHTML
6/16/2011
How to change css padding property using javascript dynamically
Labels:
Javascript
Subscribe to:
Post Comments (Atom)
Thanks sir it lot of help me my search ends here
ReplyDeletecan u tell the same in jquery how we use it
Jquery is very easy.
Deletevar ab = 20px;
jQuery(document).ready(function(){
jQuery("#div_Id").css("padding", ab);
});