473,379 Members | 1,330 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

Getting CSS containt using JS from <style> tag

How can i get css contains of an element.
When i use alert(document.getElementById('mydiv').style.opaci ty) it will return empty.

Expand|Select|Wrap|Line Numbers
  1. <style>
  2. #mydiv{
  3. background:#000000;
  4. opacity:0.4;
  5. }
  6. </style>
  7.  
  8. <div id="mydiv">inner</div>
  9.  
Expand|Select|Wrap|Line Numbers
  1. <script>
  2. function getOpacity(){
  3. alert(document.getElementById('mydiv').style.opacity); // it returns an empty message box
  4. }
  5. </script>
  6.  
Aug 12 '09 #1
1 2013
Dormilich
8,658 Expert Mod 8TB
that depends on when you define and call the JS/CSS. though it could also be that you have to access those CSS with getComputedStyle()
Aug 12 '09 #2

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

Similar topics

14
by: Ian Rastall | last post by:
I'm curious as to the group's feelings about using the <fieldset> and <legend> tags around elements other than <form> elements ... I wrote a small test file:...
37
by: Haines Brown | last post by:
I understand that <br /> is marginal in CSS, and so am looking for a substitute for the EOL character. I've failed in both approaches and seek advice. The first thing I tried was to use the...
5
by: toylet | last post by:
Attached is some css codes for a website. It has 3 parts: top-bar, side-bar (on the left) and main-body. The top-bar has a mouseover menu called top-menu implemented via ul:hover. When the mouse...
2
by: listaction | last post by:
Hi Folks, can you help me by explaining how the code below can be translated using <div> and achieve the same effect? Thanks, LA <html> <body> <table bgcolor="#000000" width="100%"...
15
by: Matthias Hullin | last post by:
Hi, I'm programming some PHP discussion board that is supposed to appear inside the content area of a proprietary CMS. As I need some more styles than the standard stylesheet provides, I just...
6
by: Ken Varn | last post by:
I want to add my own custom <STYLE> section in the <HEAD> section of my ASP.NET page within a custom control. Can someone tell me how I can have my custom control add tags to the <HEAD> section of...
2
by: Chuck | last post by:
I am using an asp.net page and I am trying to setup a customers website. The website uses a ssl certificate from verisign and the customer would like to use the seal. The new style from VeriSign is...
8
by: Taras_96 | last post by:
Hi everyone, We' ve come to the conclusion that we wish the user to be directed to an error page if javascript is disabled <enter comment about how a webpage shouldn't rely on javascript here :)...
6
goatboy
by: goatboy | last post by:
So I am hosting a site from my home server, and I would like the main page to be an area for updates about the site. I am providing these updates in a blog-style format, using this code: ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.