Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* Rambutan ;) */
- &&& &&&& &&& &&&
- ¤¤ NOTERINGAR ¤¤
- &&& &&&& &&& &&&
- slideToggle(divens_id, divens_höjd, slide_hastighet);
- Glöm inte ha overflow:hidden; på :)
- &&& &&&& &&&
- ¤¤¤ HTML ¤¤¤
- &&& &&&& &&&
- <div style="width:400px;height:20px;text-align:center;background:green;" onclick="slideToggle('my_div',200,3);">Slideopen div</div>
- <div id="my_div" style="height:0px;width:400px;background:pink;overflow:hidden;">
- ...content...
- </div>
- &&& &&&& &&& &&& &&&&
- ¤¤¤¤¤ JAVASCRIPT ¤¤¤¤
- &&& &&&& &&&& &&& &&&
- var open = 0; // öppen eller stängd från början? (funkar typ inte :P)
- var height = 0; //ursprunglig höjd
- function slideToggle(divId,divHeight,divSpeed) {
- if(open == 0) {
- open = 1;
- slidePlus(divId,divHeight,divSpeed);
- }
- else if(open == 1) {
- open = 0;
- slideMinus(divId,divHeight,divSpeed);
- }
- }
- function slidePlus(divId,divHeight,divSpeed) {
- if(height <= divHeight) {
- document.getElementById('tjohej_div').style.visibility="visible";
- height = height + divSpeed;
- document.getElementById('tjohej_div').style.height=height + 'px';
- window.setTimeout(function(){slidePlus(divId,divHeight,divSpeed)}, 1);
- }
- }
- function slideMinus(divId,divHeight,divSpeed) {
- if(height >= 0) {
- document.getElementById('tjohej_div').style.visibility="visible";
- height = height - divSpeed;
- document.getElementById('tjohej_div').style.height=height + 'px';
- window.setTimeout(function(){slideMinus(divId,divHeight,divSpeed)}, 1);
- } else {
- document.getElementById(divId).style.visibility="hidden";
- }
- }
Add Comment
Please, Sign In to add comment