473,385 Members | 1,645 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,385 software developers and data experts.

create a span tag

Hello javascript newsgroup,

Sorry for my bad english please...

Today I have write some of my first JS scripts.

My problem is to create a <spantag in the div tag with the name
"favoriten".

In the first step I create the span tag in the "hinzufügen" function
in my JS. The function is called when someone clicked a picture on my
site (onclick).
After that the span tag is create, but not exactly in my div
"favoriten"... The span tag is create on the top of my site...

Here I paste my code...

JS file (favoriten.js)
------------------------------
function hinzufügen() {

var favoritenDiv = document.getElementById("favoriten");
var auswahl = this;

var favobilder = favoritenDiv.getElementsByTagName("img");

if( favobilder.length < 3 ) {
favoritenDiv.appendChild(auswahl);
auswahl.onclick = null;
}
else {
alert("Es sind schon 3 Bilder in den Favoriten");
}

//Create a span tag
var neuSpanElement = document.createElement("span");
neuSpanElement.className = "rang";
var neuTextElement = document.createTextNode(5);
neuSpanElement.appendChild(neuTextElement);
favoritenDiv.appendChild(neuSpanElement);

}
------------------------------

html site: (index.html)
------------------------------
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<style type="text/css">

..rang {

position:absolute;
text-align:center;
top:20px;
font-size:small;
background-color:#FFFFFF;
border:thin solid black;
width:20px;
z-index:99;

}

</style>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"
/>

<script type="text/javascript" src="favoriten.js"></script>
</head>

<body onload="autostart()">
<div id="part1">Hier eine Auswahl von Pics:</div>

<div id="bild">
<img src="images/elefant.jpg" />
<img src="images/kaffee.jpg" />
<img src="images/ajax.jpg" />
<img src="images/entwurfsmuster.jpg" />

</div>

<div id="part2">Hier deine Favorieten:</div>
<div id="favoriten">
</div>

</body>
</html>
------------------------------

Dec 22 '06 #1
1 2024
ASM
se*****************@googlemail.com a écrit :
>
After that the span tag is create, but not exactly in my div
"favoriten"... The span tag is create on the top of my site...
not at all, your span is certainly in your div

but ... your css about class 'rang' tells :

..rang {
position:absolute;
top:20px;

and means 'rang' on top of page at 20px
because your div "favoriten" has no style position

give { position:relative; } to the div "favoriten"
or delete position:absolute; from 'rang'

--
Stephane Moriaux et son (moins) vieux Mac déjà dépassé
Stephane Moriaux and his (less) old Mac already out of date
Dec 23 '06 #2

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

Similar topics

7
by: deko | last post by:
How to change a link's color based on a php variable? I have a number of links on a page: <p><a href="page1.php">Page 1</a></p> <p><a href="page2.php">Page 2</a></p> <p><a...
3
by: effendi | last post by:
I know this sounds like javascript menu and perhaps it is, but I have taken a look at menu codes and found it too difficult to revamp quickly. What I would like to do is a place a text is my...
2
by: ricky | last post by:
Hello, If anyone could help me with this I would highly appreciate it. I've tried everything and nothing works. What I am trying to do is so damn basic and it's just frustrating that it seems...
0
by: casper | last post by:
Hi, I use asp.net 2.0 and VWD (and sqlserver 2005 express) on windows 2000 sp4.. Starting from VWD, it works. Starting from the browser, the code below produces this error: CREATE DATABASE...
2
by: Krustov | last post by:
The question of how to create thumbnails with clickable links gets asked on this newsgroup every so often - like clock work . Just really posing this script here for google to archive it & so...
15
by: pbd22 | last post by:
Hi. I want to create a tab with a little "active tab" arrow below it to tell the user where they are. An example is here: http://personals.yahoo.com/us/search/dashboard Does anybody know of...
4
by: mark4asp | last post by:
I want to write a xslt template to create a xhtml 1.0 (transitional) file which will be sent in as email. Here is a typical xml data file: <BatchEmail> <Domain>www.myDomain.com</Domain>...
2
by: nja2222 | last post by:
I would like to create a page for my clients to login and check for updates on their accounts. Then I would like to create a page where my employees can login and make updates, specifically new file...
0
by: tiingshii | last post by:
i have this working ----- http://pddesignstudio.com/ckc/php2 now i want to create spacing between each school how do i do it? can anyone help mi its my first time dealing with php PHP CODE ...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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.