473,994 Members | 7,949 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

javascript class style properties

If I have the following:

<style type="text/css">
..nd {
display : none;
}
</style>
<input type="checkbox" id="b1" class="nd"/>

how do I tell (in javascript) that the checkbox's display status is
currently none?

TIA
Regards
Paul
Jul 5 '06 #1
3 2008
Paul Lautman wrote:
If I have the following:

<style type="text/css">
.nd {
display : none;
}
</style>
<input type="checkbox" id="b1" class="nd"/>

how do I tell (in javascript) that the checkbox's display status is
currently none?
From a Matt Kruze post (wrapped for posting);

function getObjectStyleV alue(obj,proper ty) {
if (obj.currentSty le) {
return obj.currentStyl e[property];
}
else if (obj.document && obj.document.de faultView
&& obj.document.de faultView.getCo mputedStyle) {
return obj.document.de faultView.getCo mputedStyle(obj ,
'').getProperty Value(property) ;
}
return null;
}

--
Rob
Jul 5 '06 #2
RobG wrote:
Paul Lautman wrote:
>If I have the following:

<style type="text/css">
.nd {
display : none;
}
</style>
<input type="checkbox" id="b1" class="nd"/>

how do I tell (in javascript) that the checkbox's display status is
currently none?

From a Matt Kruze post (wrapped for posting);

function getObjectStyleV alue(obj,proper ty) {
if (obj.currentSty le) {
return obj.currentStyl e[property];
}
else if (obj.document && obj.document.de faultView
&& obj.document.de faultView.getCo mputedStyle) {
return obj.document.de faultView.getCo mputedStyle(obj ,
'').getProperty Value(property) ;
}
return null;
}
Cheers for that
Jul 5 '06 #3
Paul Lautman wrote:
RobG wrote:
>From a Matt Kruze post (wrapped for posting);
function getObjectStyleV alue(obj,proper ty) {
[snip]
Cheers for that
Check out a more robust version at:
http://www.javascripttoolbox.com/lib/util/

// Get the currently-applied style of an object
css.getStyle = function(o, property) {
if (o==null) { return null; }
var val = null;
var camelProperty = css.hyphen2came l(property);
// Handle "float" property as a special case
if (property=="flo at") {
val = css.getStyle(o, "cssFloat") ;
if (val==null) {
val = css.getStyle(o, "styleFloat ");
}
}
else if (o.currentStyle && defined(o.curre ntStyle[camelProperty])) {
val = o.currentStyle[camelProperty];
}
else if (window.getComp utedStyle) {
val = window.getCompu tedStyle(o,null ).getPropertyVa lue(property);
}
else if (o.style && defined(o.style[camelProperty])) {
val = o.style[camelProperty];
}
// For color values, make the value consistent across browsers
// Convert rgb() colors back to hex for consistency
if (/^\s*rgb\s*\(/.test(val)) {
val = css.rgb2hex(val );
}
// Lowercase all #hex values
if (/^#/.test(val)) {
val = val.toLowerCase ();
}
return val;
};
--
Matt Kruse
http://www.JavascriptToolbox.com
http://www.AjaxToolbox.com
Jul 5 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
2031
by: Alex Fitzpatrick | last post by:
Just by way of introduction, I'm currently the principal developer and maintainer of the a JavaScript editor plug-in for Eclipse. https://sourceforge.net/projects/jseditor/ The plug-in as it stands supports syntax highlighting and outlining of functions, classes and their methods.] When I took over the project in June it was for the purpose of adding outlining facilities for JavaScript written in an OO style with classes and so on. I...
5
2572
by: googlegroups | last post by:
I have a large table in html created dynamically. This table can grow to several hundred rows or more. I have the ability to hide or display individual rows (using row.style.display = "none") and this works well in both IE and Firefox. I would also like to do the same with columns as well. I did some research and col and colgroup nodes are not supported fully in both browsers. Also, doing "visibility: hidden" and sometimes "display:...
15
4270
by: binnyva | last post by:
Hello Everyone, I have just compleated a JavaScript tutorial and publishing the draft(or the beta version, as I like to call it) for review. This is not open to public yet. The Tutorial is avaliable at... http://www.geocities.com/binnyva/code/javascript/advanced_tutorial/ If any of you could spare the time, please have a look at my tutorial
7
7449
by: Kevin Newman | last post by:
I've been toying with a namespace manager, and wanted to get some input. So what do you think? if (typeof com == 'undefined') var com = {}; if (!com.unFocus) com.unFocus = {}; com.unFocus.Namespaces = new function() { this.register = function(namespace) { namespace = namespace.split('.');
2
2854
by: Alex | last post by:
Hi all, I'm writing a small web application which searches a database based on a date field, and populates a datagrid control with the results. The datagrid control has selection buttons added to it to view additional details about the selected result (a second database query is triggered). I want this second query to pop up in a new window, the way it would if I used "window.open" in javascript. I've added a function in the
37
3618
by: pochartrand | last post by:
Hello, Is there a way to manipulate or at least read the pseudo-class of an element ? I know the style attribute can be accessed and gives the CSS properties for a particular element. However, I can't seem to access the "hover" properties. example :
2
2196
by: verci | last post by:
Hi guys, sorry if this seems stupid but I'm a newbie, I'm running Windows XP Pro SP2, IE 7, VS2005, ASP.net 2.0 The problem is that I'm trying to display this news scroller made in a Javascript file(newsscroller.js) in my ASP page, everything works great in a normal HTML page, I can see the scroller just fine, but in an ASP page it just does not show, I get some error message that the control has not been initialize, so far I've been...
0
10239
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11504
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
11747
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
11005
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
6513
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
5268
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4841
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3853
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.