IntelliJ Java IDE
The moose likes HTML, CSS and JavaScript and the fly likes set margin properties of image at runtime Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Engineering » HTML, CSS and JavaScript
Reply Bookmark "set margin properties of image at runtime" Watch "set margin properties of image at runtime" New topic
Author

set margin properties of image at runtime

pravin rasal
Ranch Hand

Joined: Jul 27, 2011
Posts: 50
I have one div in html and I want to set image and its margin property at runtime. I written following code in JavaScript file but the css class 'air' cannot be apply to image. In class air I set its margin style like {10px 10px 10px 10px}


Devaka Cooray
Saloon Keeper

Joined: Jul 29, 2008
Posts: 2595

Why do you need a \" before the 'class' attribute?


Author of ExamLab - the free mock exam kit for SCJP / OCPJP
Home Page -- Twitter Profile -- JavaRanch FAQ -- How to Ask a Question
Eric Pascarello
author
Rancher

Joined: Nov 08, 2001
Posts: 15003
Get rid of the double quotes around class.



Eric
pravin rasal
Ranch Hand

Joined: Jul 27, 2011
Posts: 50
Thank you!
My post solved
Kavisha Paranamana
Greenhorn

Joined: Jul 30, 2011
Posts: 15

If changing the class is all what you need, it's better that you assign an id to the image element, and change the class Class of this element can be simply changed with jquery as below:

Kavisha Paranamana - Homepage
Bear Bibeault
Author and opinionated walrus
Marshal

Joined: Jan 10, 2002
Posts: 50691

Replacing the whole image element in order to change the class is using atom bombs to crack walnuts. Just change the class on the existing element as shown above.


[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
 
 
subject: set margin properties of image at runtime
 
Threads others viewed
DIV shrinks to fit its content
using Sprite as background
Need help editing some css if possible (SOLVED)
Clickable Div Background image
class= operation
MyEclipse, The Clear Choice

cast iron skillet 49er

more from paul wheaton's glorious empire of web junk: cast iron skillet diatomaceous earth rocket mass heater sepp holzer raised garden beds raising chickens lawn care CFL flea control missoula heat permaculture