Beste,
Ik ben momenteel met een script bezig.
Dit script heeft een Hide / Show functie, echter staat het standaard op Show.
Ik wil de functie op "Hide" hebben zodat het onderste gedeelte ingeschoven is, Ik kan helaas zelf niet in het script vinden waar de fout zit..
Hier heb ik ook een voorbeeld, momenteel ziet het er zo uit:
En het moet er zo uitzien dat het onderste gedeelte weg is, zodat er meerdere onder elkaar kunnen komen:
Dit is het script:
Code
<div class="button" id="button2" onClick="button2()" class="buttonControl" aria-controls="t2">
<div class="img"><img src="http://www.smaffia.nl/ingame/images/vlaggen/amerika.png" width="17" height="14" border="0" alt="Amerika"> </div>
<div class="land">Amerika</div>
<div class="bezit">KOGELFABRIEK</div>
<div class="kogels-img"></div>
<div class="kogels">1.000</div>
<div class="produceren">Nee</div>
<div class="prijs">€ 250,-</div>
<div class="bank">€ 0,-</div>
<div class="omzet-img"><img src='images/gebruiker/bank.png' alt='bank'></div>
<div class="omzet">€ 0,-</div>
<div class="slide"><img src='images/arrow-down.png' width="17" border="0" alt="slide"></div>
</div>
<div id="t2" class="topic" role="region" aria-labelledby="t2-label" tabindex="-1" aria-expanded="false">
<h2>STATISTIEKEN</h2>
<div class="content-sub-divider"></div>
<table>
<tr>
<td width="20px"><img src="images/icons/icon-content-upgrades.png" alt="img" /></td>
<td width="200px">Prijs</td>
<td width="200px">€ 250,- </td>
</tr>
<tr>
<td width="20px"><img src="images/icons/icon-content-connectielevel.png" alt="img" /></td>
<td width="200px">Verkocht</td>
<td width="200px">0 kogels</td>
</tr>
<tr>
<td width="20px"><img src="images/icons/icon-content-uurloon.png" alt="img" /></td>
<td width="200px">Winst</td>
<td width="200px">€ 0,-</td>
</tr>
</table>
<br />
<h2>ACTIVEREN</h2>
<div class="content-sub-divider"></div>
<br />
<table>
<tr>
<td width="20px"><img src="images/gebruiker/robot.png" width="90%" alt="img" /></td>
<td width="200px">Produceren van kogels</td>
<td width="200px">
<select name="produceren">
<option value="Ja">Ja</option>
<option value="Nee">Nee</option>
</select>
</td>
</tr>
<tr>
<td width="20px"><img src="images/gebruiker/koop.png" width="90%" alt="img" /></td>
<td width="200px">Inkopen van kogels</td>
<td width="200px">
<select name="inkopen">
<option value="Ja">Ja</option>
<option value="Nee">Nee</option>
</select>
</td>
</tr>
<tr>
<td width="20px"> </td>
<td width="200px"> </td>
<td width="200px"> </td>
</tr>
<tr>
<td width="20px"><img src="images/save.png" width="90%" alt="img" /></td>
<td width="200px">Opslaan</td>
<td width="200px"><input class="submit" id="submit" onclick="myFunction()" value="De gegevens opslaan"/></td>
</tr>
</table>
<br />
<h2>CONFIGURATIE</h2>
<div class="content-sub-divider"></div>
<br />
<table>
<tr>
<td width="20px"><img src="images/gebruiker/inkoop.png" width="90%" alt="img" /></td>
<td width="200px">Inkoop prijs</td>
<td width="200px"><input type="number" id="name" min="0" max="1000" step="1" value="250"></td>
</tr>
<tr>
<td width="20px"><img src="images/gebruiker/prijs.png" width="90%" alt="img" /></td>
<td width="200px">Verkoop prijs</td>
<td width="200px"><input type="number" name="points" id="name" min="0" max="1000" step="1" value="250"></td>
</tr>
<tr>
<td width="20px"> </td>
<td width="200px"> </td>
<td width="200px"> </td>
</tr>
<tr>
<td width="20px"><img src="images/save.png" width="90%" alt="img" /></td>
<td width="200px">Opslaan</td>
<td width="200px"><input class="submit" id="submit" onclick="myFunction()" value="De gegevens opslaan"/></td>
</tr>
</table>
</div>
Toon Meer
En dit is het stukje Javascript:
Code
$(document).ready(function() {
var hs1 = new hideShow('button1');
var hs2 = new hideShow('button2');
var hs3 = new hideShow('button3');
var hs4 = new hideShow('button4');
}); // end ready()
//
// function hideShow() is the constructor for a hideShow widget. it accepts the html ID of
// an element to attach to.
//
// @param(id string) id is the html ID of the element to attach to
//
// @return N/A
//
function hideShow(id) {
this.$id = $('#' + id);
this.$region = $('#' + this.$id.attr('aria-controls'));
this.keys = {
enter: 13,
space: 32
};
this.toggleSpeed = 100;
// bind handlers
this.bindHandlers();
} // end hidShow() constructor
//
// Function bindHandlers() is a member function to bind event handlers to the hideShow region
//
// return N/A
//
hideShow.prototype.bindHandlers = function() {
var thisObj = this;
this.$id.click(function(e) {
thisObj.toggleRegion();
e.stopPropagation();
return false;
});
}
//
// Function toggleRegion() is a member function to toggle the display of the hideShow region
//
// return N/A
//
hideShow.prototype.toggleRegion = function() {
var thisObj = this;
// toggle the region
this.$region.slideToggle(this.toggleSpeed, function() {
if ($(this).attr('aria-expanded') == 'false') { // region is collapsed
// update the aria-expanded attribute of the region
$(this).attr('aria-expanded', 'true');
// move focus to the region
$(this).focus();
// update the button label
thisObj.$id.find('span').html('Hide');
}
else { // region is expanded
// update the aria-expanded attribute of the region
$(this).attr('aria-expanded', 'false');
// update the button label
thisObj.$id.find('span').html('Show');
}
});
} // end toggleRegion()
Toon Meer
Hopend kan iemand mij helpen.
Met vriendelijke groeten,
Kevin