SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Threaded View

  1. #1
    SitePoint Member
    Join Date
    Jun 2012
    0 Post(s)
    0 Thread(s)

    Is it possible to manipulate CSS properties of an HTMLElement in JavaScript?

    I use "Chrome" developer tools JavaScript console a lot to experiment dynamically with different properties and execute different JavaScript methods, etc, directly in the console.

    I want to know how I can set CSS properties on HTMLElements directly on the elements without using the .style CSSStyleDeclaration object. Is this even possible?

    I have tried changing the .offsetLeft property to dynamically move a <div></div> on the page to see the effects but when I try changing the value it doesn't change and, of course, the HTMLDivElement doesn't move on screen. How do I manipulate these CSS properties on these HTMLElements in real-time through the JavaScript console without going through the .style CSSStyleDeclaration object. I guess that's the best way I can phrase my question. I hope my question can be understood.

    Thanks for the help.

    P.S. I have used the .css method in jQuery to do this but I want to know if it can be in regular JavaScript code. Not jQuery. Thanks.
    Last edited by ig-88; Dec 4, 2012 at 15:51. Reason: because I can


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts