Hi, ich will einem <div> -Element eine neue Klasse zuweisen:
<div id="xxxxx" class="xxxx1"></div>
zu:
<div id="xxxxx" class="xxxx2"></div>
und das will ich per javascript schaffen.
Und wenn das nicht geht, muss ich das element "xxxx1" mit js verändern, das schaff ich aber auch nicht:
function xxxxx() {
var xxxx = document.getElementById("xxxx1");
if (xxxx.style.width == "600px") {
xxxx.style.width = "100%";
}
else {
xxxx.style.width = "600px";
}
if (xxxx.style.height == "400px") {
xxxx.style.height = "100%";
}
else {
xxxx.style.height = "400px";
}
if (xxxx.style.top == "50%") {
xxxx.style.top = "0";
}
else {
xxxx.style.top = "50%";
}
if (xxxx.style.left == "50%") {
xxxx.style.left = "0";
}
else {
xxxx.style.left = "50%";
}
if (xxxx.style.margin-left = "-300px") {
xxxx.style.margin-left = "0";
}
else {
xxxx.style.margin-left = "-300px";";
}
if (xxxx.style.margin-top = "-200px") {
xxxx.style.margin-top = "0";
}
else {
xxxx.style.margin-top = "-200px";";
}
}
Kann mir einer hier den Fehler verraten, und gibt es dazu auch eine Elegantere Lösung.
Danke