Skip to content
CodeWorth
CodeWorth

Code worths when shared

Primary Navigation Menu
Menu
  • BLOG
    • DataBase
    • Programming
    • Mobile
    • Multimedia
    • OS Tips
    • Others
    • Web Development
  • Products
    • Utilities
    • Games
    • JsGenLib
      • PlugIns
      • Core Functions
      • Helper & ShortHands
  • About

Setting CSS/Style float from javascript

On September 22, 2009
In Web Development
Tagged Browsers, CSS, JavaScript, Web
With 0 Comments
If we ever try to set the float of an element through Javascript, setting the element float as below is not possible because the javascript DOM doesn’t have a definiton for float on style property.
element.style.float="left";
Solutions for this are dependent on the Browsers
  • cssFloat for Firefox, Opera, Safari & Edge
    element.style.cssFloat="left";
  • For IE
    element.style.styleFloat="left";
Not only this property, the standard things to check while writing Javascript are
  • Does DOM consists of what we are writing?
  • Are we following naming convention matching to browsers DOM
    element.style.padding="0px"; // started with small letter 
    element.style.paddingLeft="0px"; //each pronounced word is capitalized
    		
  • Do we assign values as DOM is expecting from us?
    style.width="100px" //valid 
    style.width=100; //is invalid
2009-09-22

Subscribe

Enter your email address to receive notifications about new posts via email.

Join 634 other subscribers

Google

Designed using Chromatic WordPress Theme. Powered by WordPress.