By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,286 Members | 1,673 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,286 IT Pros & Developers. It's quick & easy.

Convert simple CSS to JavaScript

P: 82
Hello.
I have following CSS code:
[HTML]#container .my_href {
text-decoration: none;
}[/HTML]
How to convert it in JS?
Nov 14 '07 #1
Share this Question
Share on Google+
3 Replies


Dasty
Expert 100+
P: 101
http://codepunk.hardwar.org.uk/css2js.htm

so, obj.textDecoration in your case.
Nov 14 '07 #2

P: 82
obj.textDecoration in your case.
Yes, I know this property.
But, for example, what do i need to do with following construction?
[HTML]#container ul li a {
text-decoration: none;
}
[/HTML]
Nov 14 '07 #3

acoder
Expert Mod 15k+
P: 16,027
But, for example, what do i need to do with following construction?
[HTML]#container ul li a {
text-decoration: none;
}
[/HTML]
For that, you get the container using:
Expand|Select|Wrap|Line Numbers
  1. var container = document.getElementById("container");
then get the UL, LI and A elements using getElementsByTagName() :
Expand|Select|Wrap|Line Numbers
  1. var uls = container.getElementsByTagName("ul");
  2. for (i = 0; i < uls.length; i++) {
  3.   var lis = uls[i].getElementsByTagName("li");
  4.   for (j = 0; j < lis.length; j++) {
  5.     var links = lis[j].getElementsByTagName("a");
  6.     ...
  7.   }
  8. }
Nov 14 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.