I got two div tags. One is hardcoded, one is created on the page using
javascript.
I want the dynamically created DIV to have the same style settings
(except for two which I will change afterwards) as the static one.
I tried
staticDiv = document.GetEle mentById("stati cdiv");
dynDiv = document.GetEle mentById("dyndi v");
dynDiv.style = staticDiv.style
This does not work, because the style object has a getter but not a
setter (i.e. is readonly). This is at least the case for FireFox.
I can copy the style members one by one:
dynDiv.style.wi dth = staticDiv.style .width
and would do so if there were only four or so.
Is there any easy JavaScript way to copy all members of style?
Something like
foreach(style in dynDiv.style).. ..?
Thanks,
Kay 5 3996
On 28 Aug 2004 12:28:51 -0700, Sparhawk <Ka************ @gmx.de> wrote: I got two div tags. One is hardcoded, one is created on the page using javascript. I want the dynamically created DIV to have the same style settings (except for two which I will change afterwards) as the static one.
[snip]
Is there any easy JavaScript way to copy all members of style? Something like foreach(style in dynDiv.style).. ..?
Use a class selector and a assign the new DIV that class name.
var dyndiv;
if(document.get ElementById) {
dyndiv = document.getEle mentById('dyndi v');
if(dyndiv) {dyndiv.classNa me = 'yourClass';}
}
Hope that helps,
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
On 28 Aug 2004 12:28:51 -0700, Ka************@ gmx.de (Sparhawk) wrote: I got two div tags. One is hardcoded, one is created on the page using javascript. I want the dynamically created DIV to have the same style settings (except for two which I will change afterwards) as the static one.
I tried
staticDiv = document.GetEle mentById("stati cdiv"); dynDiv = document.GetEle mentById("dyndi v"); dynDiv.style = staticDiv.style
This does not work, because the style object has a getter but not a setter (i.e. is readonly). This is at least the case for FireFox.
I can copy the style members one by one:
dynDiv.style.wi dth = staticDiv.style .width
and would do so if there were only four or so.
Is there any easy JavaScript way to copy all members of style? Something like foreach(styl e in dynDiv.style).. ..?
Thanks, Kay
how about using a CSS class name in the original DIV then when you
create the 2nd one set its classname to the same.
dynDiv.style.cl assname = staticDiv.style .classname
(untested)
hth.
al.
On Sun, 29 Aug 2004 09:58:44 +0100, Harag
<ha************ **********@soft home.net> wrote:
[snip] dynDiv.style.cl assname = staticDiv.style .classname
The className property (note the capital N), is a direct property of the
element, not the style object.
Just so you know. :)
Mike
--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.
On 28 Aug 2004 12:28:51 -0700, Ka************@ gmx.de (Sparhawk) wrote: I got two div tags. One is hardcoded, one is created on the page using javascript. I want the dynamically created DIV to have the same style settings (except for two which I will change afterwards) as the static one.
I tried
staticDiv = document.GetEle mentById("stati cdiv"); dynDiv = document.GetEle mentById("dyndi v"); dynDiv.style = staticDiv.style
This does not work, because the style object has a getter but not a setter (i.e. is readonly). This is at least the case for FireFox.
I can copy the style members one by one:
dynDiv.style.wi dth = staticDiv.style .width
and would do so if there were only four or so.
Is there any easy JavaScript way to copy all members of style? Something like foreach(styl e in dynDiv.style).. ..?
Thanks, Kay
eg:
<!doctype html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<script type="text/javascript">
function changeClass() {
var i1=document.get ElementById("id 1");
var i2=document.get ElementById("id 2");
i1.className = i2.className;
}
</script>
<style type="text/css">
..tst1{backgrou nd: #CC0; height:150px; width:150px; padding: 5px 5px
5px 5px;}
..tst2{backgrou nd: #0CD; height:100px; width:100px; padding: 5px 5px
5px 5px;}
</style>
</head>
<body>
<p id="id1" class="tst1">th is is a test</p>
<p id="id2" class="tst2">th is is a test</p>
<input type="button" value="click me" onclick="change Class();">
</body>
</html>
On Sun, 29 Aug 2004 09:15:10 GMT, "Michael Winter"
<M.******@bluey onder.co.invali d> wrote: On Sun, 29 Aug 2004 09:58:44 +0100, Harag <ha*********** ***********@sof thome.net> wrote:
[snip]
dynDiv.style.cl assname = staticDiv.style .classname
The className property (note the capital N), is a direct property of the element, not the style object.
Just so you know. :)
Mike
LOL, Thanks, I wasn't sure I was 100% right but I was thinking along
the right lines, so I went and tested it... hence the 2nd post. This
sort of things happen when a learner helps another learner :)
Al. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Bob Halley |
last post by:
In dnspython I have a set class, SimpleSet. (I don't use Python 2.3's
sets.Set class so I can keep supporting Python 2.2, and because the
objects in my sets are mutable). The SimpleSet class has a single
attribute, "items", which is a list. (I know a list is not going to
lead to fast set operations in general, but my typical set has only
one or two elements in it, so the potential performance issues don't
really matter for my needs.)
...
|
by: Robert Tarantino |
last post by:
Hello,
I am trying to find a way to create a scheduled task or
service that will copy my local profile folders
under "Documents and settings" to a network drive. This
would allow me to restore my settings if my profile became
tampered with or corrupt. Is there any sample code
available out there?
-Robert
|
by: Lyn |
last post by:
I am trying to copy selected fields from one table to another, by reading
the source table record into a recordset (ADO) and then copying the relevant
fields to an SQL statement "INSERT INTO...". The numeric and text fields
copy without a problem, but it all falls in a heap when I try to copy a
picture object field (data type OLE Object in both tables). I seem to be
missing something ???
Reduced to its simplest form, this is the code...
|
by: solex |
last post by:
Hello,
I am trying to use serialization to copy objects. The object in question
"Institution" inherits from a parent object "Party" both are marked as
<Serializable()>. Initially I can copy an empty Institution to another
empty Institution, using the following routine:
Private Sub CopyObject(ByRef FromObject As Object, ByRef ToObject As Object)
Dim m As New MemoryStream
Dim b As New BinaryFormatter
|
by: p3t3r |
last post by:
I have a treeview sourced from a SiteMap. I want to use 2 different CSS
styles for the root level nodes. The topmost root node should not have a top
border, all the other root nodes should have a top border.
Is it possible to have more than 1 style at the same level (parent node)
when using a SiteMap?
I want it to appear something like this and I can only find a way to either
have the border on all root nodes or none at all. In...
| |
by: Jess |
last post by:
Hello,
I tried to clear a vector "v" using "v.clear()". If "v" contains
those objects that are non-built-in (e.g. string), then "clear()" can
indeed remove all contents. However, if "v" contains built-in types
(e.g. int), then "clear()" doesn't remove anything at all. Why does
"clear()" have this behaviour?
Also, when I copy one vector "v1" from another vector "v2", with "v1"
longer than "v2" (e.g. "v1" has 2 elements and "v2" has...
|
by: kimiraikkonen |
last post by:
Hi,
I use system.io.file class to copy files but i have a difficulty about
implementing a basic / XP-like progress bar indicator during copying
process.
My code is this with no progress bar, or i couldn't find sth which
give totalbytes/written bytes class. And does system.io.file class
provide awaring of the chunks / bytes of the files bytes which are
written?
|
by: Josh Valino |
last post by:
Hi,
I'd like to take the style properties from one control and apply them all to
the properties of another control, where they relate. The situation is
this:
I have a TreeView control, and the SelectedNodeStyle has some things set.
In addition to the TreeView, I have a few LinkButton controls. A user can
select a node in the tree or one of the LinkButton. I'd like the
LinkButtons to have the same look that a selected node has when...
|
by: raylopez99 |
last post by:
Beware newbies: I spent a day before I figured this out: copying a
bitmap (image) file to file is not quite like copying a text file--you
have to do some tricks (see below), like using a "Graphics" object to
wrap around the image (!). It's not so simple as shown in most
examples (where they have a simple image file and hard copy it into a
harddrive along the lines of : image.Save(@"C:\\temp\\myimage.pgn");
That will work, but it's a...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
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...
|
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,...
|
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...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
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...
|
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
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |