get style from element
get style from element
get style from element
get style from element
get style from element
get style from element get style from element get style from element get style from element get style from element get style from element get style from element get style from element
get style from element get style from element
get style from element
Go Back  Xtreme Visual Basic Talk > > > get style from element


Reply
 
Thread Tools Display Modes
  #1  
Old 01-08-2013, 05:53 PM
jason78944545 jason78944545 is offline
Centurion
 
Join Date: Feb 2008
Posts: 111
Default get style from element


hi,
i have some style property in a array for example

color[1] = "color";
color[2] = "background";

now i want ger the style property of a object but i don´t know
how call.

for example: obj.style + color[1] but this only return:

[object CSSStyleDeclaration], how can i see the value that is set?
thanks for your help
Reply With Quote
  #2  
Old 01-11-2013, 12:07 AM
saltyfish saltyfish is offline
Newcomer
 
Join Date: Jan 2013
Location: Jakarta
Posts: 2
Smile

I assume u r using Javascript, okay here's a simple example:
First, lets say u have an object named myDiv

Code:
<div id="myDiv" style="color:black; background-color:yellow">
	I'm a text inside a DV
</div>

<script type="text/javascript">
	var fontColor;
	var backColor;
	fontColor = document.getElementById("myDiv").style.color;
	backColor = document.getElementById("myDiv").style.backgroundColor;
	
	alert("The color is " + fontColor + " and the background color is " + backColor);
</script>
The document.getElementById("object_id") is a keyword to select an object based on its ID.
The document.getElementsByName("object_name") will select the object based on its its Name attribute (this ussualy applied to the form's objects such FORM, INPUT, or TEXTAREA)
The document.getElementsByTagName("tag_name") will select the object based on its tag name (note that this will return an object array)

hope that help, any suggestion to improve the code better would be appreciated..
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
get style from element
get style from element
get style from element get style from element
get style from element
get style from element
get style from element get style from element get style from element get style from element get style from element get style from element get style from element
get style from element
get style from element
 
get style from element
get style from element
 
-->