problema conditia if else

Vezi subiectul anterior Vezi subiectul urmator In jos

Rezolvat problema conditia if else

Mesaj Scris de VeteraNNN la data de Joi 31 Ian - 18:07

Cod:
$(function(){
if ($("a#toggle_sidebar").length > 0) {
$('#toggle_sidebar').click(function() {
$('#dw_right').show();
$('#content-container div#container').css('width','83%');
});
}
else {
$('#toggle_sidebar').click(function() {
$('#dw_right').hide();
$('#content-container div#container').css('width','100%');
});
}
});

ce am gresit de nu merge ?


Ultima editare efectuata de catre VeteraNNN in Sam 2 Feb - 17:53, editata de 1 ori

VeteraNNN
Membru activ

masculin

Mesaje : 485
Varsta : 22
Localizare : Undeva in spatele tau !!
Data de inscriere : 28/10/2012
Multumiri : 0
Membru exclus

Sus In jos

Rezolvat Re: problema conditia if else

Mesaj Scris de Omu la data de Joi 31 Ian - 20:10

Pai ne poti spune ce se intampla cand ruleaza? think Posteaza un link unde ai lucrat.
Incearca totusi..
Cod:
$(function () {
    if ($("a#toggle_sidebar").length > 0) {
        $('#toggle_sidebar').click(function () {
            if(!$(this).is(':visible'))
            {
                $('#dw_right').show();
                $('#content-container div#container').css('width', '83%');
            }
            else
            { 
                $('#dw_right').hide();
                $('#content-container div#container').css('width', '100%');
            }
        });
    }
});

Omu
Membru onorific
Membru onorific

masculin

Mesaje : 6310
Varsta : 20
Data de inscriere : 04/11/2010
Multumiri : 153
Niciun avertisment

http://www.tech-titans.net/

Sus In jos

Rezolvat Re: problema conditia if else

Mesaj Scris de .razvan la data de Joi 31 Ian - 20:27

ai un if dupa inca un if .. trb sa folosesti conditia if{ bla bla bla } else if {bla bla bla} else{ bla bla bla} nu merge asa bine cu doi de if

.razvan
Contribuitor suport
Contribuitor suport

Mesaje : 428
Data de inscriere : 22/08/2011
Multumiri : 9
Niciun avertisment

http://www.fg-coding.net/

Sus In jos

Rezolvat Re: problema conditia if else

Mesaj Scris de VeteraNNN la data de Vin 1 Feb - 13:59

ma poti ajuta .razvan ?

VeteraNNN
Membru activ

masculin

Mesaje : 485
Varsta : 22
Localizare : Undeva in spatele tau !!
Data de inscriere : 28/10/2012
Multumiri : 0
Membru exclus

Sus In jos

Rezolvat Re: problema conditia if else

Mesaj Scris de Omu la data de Vin 1 Feb - 19:15

Ai incercat macar codul dat de mine?

Omu
Membru onorific
Membru onorific

masculin

Mesaje : 6310
Varsta : 20
Data de inscriere : 04/11/2010
Multumiri : 153
Niciun avertisment

http://www.tech-titans.net/

Sus In jos

Rezolvat Re: problema conditia if else

Mesaj Scris de VeteraNNN la data de Vin 1 Feb - 19:17

scuze omu acuma il incerc si iti dau raspunsul Fericit
PS: Omu functioneaza dar nu il poti face sa aiba si functia .toggle() ?

VeteraNNN
Membru activ

masculin

Mesaje : 485
Varsta : 22
Localizare : Undeva in spatele tau !!
Data de inscriere : 28/10/2012
Multumiri : 0
Membru exclus

Sus In jos

Rezolvat Re: problema conditia if else

Mesaj Scris de Omu la data de Vin 1 Feb - 19:27

Toggle unde anume?

Omu
Membru onorific
Membru onorific

masculin

Mesaje : 6310
Varsta : 20
Data de inscriere : 04/11/2010
Multumiri : 153
Niciun avertisment

http://www.tech-titans.net/

Sus In jos

Rezolvat Re: problema conditia if else

Mesaj Scris de VeteraNNN la data de Vin 1 Feb - 19:34

Uite la asta Omu [Trebuie sa fiti inscris si conectat pentru a vedea acest link]

VeteraNNN
Membru activ

masculin

Mesaje : 485
Varsta : 22
Localizare : Undeva in spatele tau !!
Data de inscriere : 28/10/2012
Multumiri : 0
Membru exclus

Sus In jos

Rezolvat Re: problema conditia if else

Mesaj Scris de Omu la data de Vin 1 Feb - 19:49

Deci tu vrei ca atunci cand dai click pe "X" sa dispara widgeturile si sa se lungeasca categoria? Fara partea HTML este ceva mai complicat, dar incearca totusi:
Cod:
  $(function () {   
    $('#toggle_sidebar').addclass('toggle_sidebar2');
    $('.toggle_sidebar2').click(function () {
          $('#dw_right').hide();
          $('#content-container div#container').css('width', '100%');
    });
    $('#toggle_sidebar').click(function () {
          $('#dw_right').show();
          $('#content-container div#container').css('width', '83%');
    });
  });

Omu
Membru onorific
Membru onorific

masculin

Mesaje : 6310
Varsta : 20
Data de inscriere : 04/11/2010
Multumiri : 153
Niciun avertisment

http://www.tech-titans.net/

Sus In jos

Rezolvat Re: problema conditia if else

Mesaj Scris de VeteraNNN la data de Vin 1 Feb - 20:02

Nu merge Supărat
Alte idei nu mai ai ?

VeteraNNN
Membru activ

masculin

Mesaje : 485
Varsta : 22
Localizare : Undeva in spatele tau !!
Data de inscriere : 28/10/2012
Multumiri : 0
Membru exclus

Sus In jos

Rezolvat Re: problema conditia if else

Mesaj Scris de Omu la data de Vin 1 Feb - 20:07

HTML:
Cod:
<a id="toggle_sidebar">X</a>
<div id="dw_right">Continutul tau aici</div>
Javascript:
Cod:
      $(function () { 
        $('#toggle_sidebar').addclass('toggle_sidebar2');
        $('a.toggle_sidebar2').click(function () {
              $('#dw_right').hide();
              $('#content-container div#container').css('width', '100%');
        });
        $('#toggle_sidebar').click(function () {
              $('#dw_right').show();
              $('#content-container div#container').css('width', '83%');
        });
      });

Omu
Membru onorific
Membru onorific

masculin

Mesaje : 6310
Varsta : 20
Data de inscriere : 04/11/2010
Multumiri : 153
Niciun avertisment

http://www.tech-titans.net/

Sus In jos

Rezolvat Re: problema conditia if else

Mesaj Scris de VeteraNNN la data de Vin 1 Feb - 20:17

uite codul folosit de mine
Cod:
$(function(e) {
$('#content-container div#container').css('width','83%');
$('#content-container div#container').after('<a href="#" id="toggle_sidebar" title="" data-closed="«" data-open="Ś" onclick="#">Ś</a><div id="dw_right"><ul class="dwtheme">
<li>phpBB3 - Theme</li>
<li id="id-1"> <a href="/t14-carbon-blue" id="carbon_blue">1. Carbon Blue</a><span id="views"></span></li>
<li id="id-2"> <a href="/t34-overlay-bluberry">2. Overlay Bluberry</a><span id="views"></span></li>
<li id="id-3"> <a href="/t31-uniform">3. Uniform</a><span id="views"></span></li>
<li id="id-4"> <a href="/t5-ip-board-default">4. IP. Board Default</a><span id="views"></span></li>
<li id="id-5"> <a href="/t21-es-blue-v1">5. ES Blue v1</a><span id="views"></span></li>
<li id="id-6"> <a href="/t96-photoshop-glosy">6. PhotoShop Glosy</a><span id="views"></span></li>
<li id="id-7"> <a href="/t50-uniform-blue">7. Uniform Blue</a><span id="views"></span></li>
<li id="id-8"> <a href="/t4-blue-sensivity">8. Blue Sensivity</a><span id="views"></span></li>
<li id="id-8"> <a href="/t51-proglass">9. proglass</a><span id="views"></span></li>
<li id="id-10"> <a href="/t133-kevin-cods-v1#406">10. Kevin-Cods v1</a><span id="views"></span></li>
</ul>
<br />
<ul class="dwtheme">
<li>punBB - Theme</li>
<li id="id-1"> <a href="/t16-blue-white">1. Blue White</a><span id="views"></span></li>
<li id="id-10"> <a href="/t89-anonymous">2. Anonymous</a><span id="views"></span></li>
</ul>
<br />
<ul class="dwtheme">
<li>Premium - Theme</li>
<li id="id-1"> <a href="/t102-premium-final-supernova-blue">1. Supernova Blue [Price]</a><span id="views"></span></li>
<li id="id-10"> <a href="/t75-premium-navia">2. Navia [Free]</a><span id="views"></span></li>
</ul>
<br />
<ul class="dwtheme">
<li>Last Members Online</li>
<li id="latest_online_members"></li>
</ul>
<br />
<ul class="dwtheme">
<li>Online Staff</li>
<li id="staff"><img src="http://ipbforumskins.com/skindemo/public/style_images/wireless/post_offline.png" alt="" class="post_online" data-tooltip="Offline" id="anonymous_element_5"> <i>Not new online staff</i></li>
</ul>
<br />
<ul class="dwtheme">
<li>Statistics</li>
<li id="id-1">Total Topic: <span id="dw_topic"></span></li>
<li id="id-2">Total Post: <span id="dw_post"></span></li>
<li id="id-3">Total User: <span id="dw_user"></span></li>
<li id="id-10">Most Online: <span id="dw_online"></span></li>
</ul>
<style>.dwtheme li:nth-child(1) {
background: url("http://i48.servimg.com/u/f48/17/48/49/15/highli19.png") repeat-x scroll 0 0 #EEE;
border: 1px solid #D8D8D8;
clear: both;
margin-left: -6px;
margin-right: -6px;
padding: 5px 8px;
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
position: relative;
top: -6px;
}

.dwtheme {
background: whiteSmoke;
border: 1px solid #DDD;
width: 190px;
padding: 5px;
margin-left: 10px;
margin-top: 16px;
}

#id-1, #id-2, #id-3, #id-4, #id-5, #id-6, #id-7, #id-8 {
padding: 0 0 6px;
border-bottom: 1px solid #CCC;
margin-bottom: 5px;
}

#id-9, #id-10 {
padding: 0 0;
margin-bottom: 2px;
}

.dwtheme #views {
float: right;
}

div#dw_right {
display: block;
}

#dw_topic, #dw_post, #dw_user, #dw_online {
padding-left: 5px;
}

#latest_online_members a span {
display: none;
}

#latest_online_members a img {
width: 30px;
margin-right: 7px;
height: 30px;
background: white;
padding: 1px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.13);
margin-bottom: 5px;
}

#latest_online_members a span {
position: absolute;
margin-left: -45px;
margin-top: -20px;
background: #EEE;
padding: 2px 5px;
border: 1px solid;
}

#latest_online_members a:hover #latest_online_members a span {
display: block;
}

#latest_online_members {
margin-left: 14px;
}

#toggle_sidebar {
position: absolute;
right: 37px;
z-index: 8000;
background: #1988C7;
padding: 3px 7px;
-webkit-border-radius: 4px;
-moz-border-radius: 4px;
border-radius: 4px;
color: white;
opacity: 0.1;
-webkit-transition: all 0.4s ease-in-out;
-moz-transition: all 0.4s ease-in-out;
}

#toggle_sidebar:hover {
opacity: 1;
}
</style></div>');
});

$(function() {
$('#variables strong:eq(0)').clone().appendTo('#dw_topic');
$('#variables strong:eq(1)').clone().appendTo('#dw_post');
$('#variables strong:eq(2)').clone().appendTo('#dw_user');
$('#variables strong:eq(3)').clone().appendTo('#dw_online');
$('#latest_online_members').load('/memberlist #memberlist .avatar-mini a:lt(8)');
});

$(function () {
        $('#toggle_sidebar').addclass('toggle_sidebar2');
        $('a.toggle_sidebar2').click(function () {
              $('#dw_right').hide();
              $('#content-container div#container').css('width', '100%');
        });
        $('#toggle_sidebar').click(function () {
              $('#dw_right').show();
              $('#content-container div#container').css('width', '83%');
        });
      });

VeteraNNN
Membru activ

masculin

Mesaje : 485
Varsta : 22
Localizare : Undeva in spatele tau !!
Data de inscriere : 28/10/2012
Multumiri : 0
Membru exclus

Sus In jos

Rezolvat Re: problema conditia if else

Mesaj Scris de Omu la data de Vin 1 Feb - 20:30

CSS:
Cod:
#content-container div#container { width: 83% !important;}
Javascript:
Cod:
    $(function(e) {
    $('#content-container div#container').after('<a id="toggle_sidebar" class="toggle_sidebar2" data-closed="«" data-open="Ś" onclick="">Ś</a><div id="dw_right"><ul class="dwtheme">
    <li>phpBB3 - Theme</li>
    <li id="id-1"> <a href="/t14-carbon-blue" id="carbon_blue">1. Carbon Blue</a><span id="views"></span></li>
    <li id="id-2"> <a href="/t34-overlay-bluberry">2. Overlay Bluberry</a><span id="views"></span></li>
    <li id="id-3"> <a href="/t31-uniform">3. Uniform</a><span id="views"></span></li>
    <li id="id-4"> <a href="/t5-ip-board-default">4. IP. Board Default</a><span id="views"></span></li>
    <li id="id-5"> <a href="/t21-es-blue-v1">5. ES Blue v1</a><span id="views"></span></li>
    <li id="id-6"> <a href="/t96-photoshop-glosy">6. PhotoShop Glosy</a><span id="views"></span></li>
    <li id="id-7"> <a href="/t50-uniform-blue">7. Uniform Blue</a><span id="views"></span></li>
    <li id="id-8"> <a href="/t4-blue-sensivity">8. Blue Sensivity</a><span id="views"></span></li>
    <li id="id-8"> <a href="/t51-proglass">9. proglass</a><span id="views"></span></li>
    <li id="id-10"> <a href="/t133-kevin-cods-v1#406">10. Kevin-Cods v1</a><span id="views"></span></li>
    </ul>
    <br />
    <ul class="dwtheme">
    <li>punBB - Theme</li>
    <li id="id-1"> <a href="/t16-blue-white">1. Blue White</a><span id="views"></span></li>
    <li id="id-10"> <a href="/t89-anonymous">2. Anonymous</a><span id="views"></span></li>
    </ul>
    <br />
    <ul class="dwtheme">
    <li>Premium - Theme</li>
    <li id="id-1"> <a href="/t102-premium-final-supernova-blue">1. Supernova Blue [Price]</a><span id="views"></span></li>
    <li id="id-10"> <a href="/t75-premium-navia">2. Navia [Free]</a><span id="views"></span></li>
    </ul>
    <br />
    <ul class="dwtheme">
    <li>Last Members Online</li>
    <li id="latest_online_members"></li>
    </ul>
    <br />
    <ul class="dwtheme">
    <li>Online Staff</li>
    <li id="staff"><img src="http://ipbforumskins.com/skindemo/public/style_images/wireless/post_offline.png" alt="" class="post_online" data-tooltip="Offline" id="anonymous_element_5"> <i>Not new online staff</i></li>
    </ul>
    <br />
    <ul class="dwtheme">
    <li>Statistics</li>
    <li id="id-1">Total Topic: <span id="dw_topic"></span></li>
    <li id="id-2">Total Post: <span id="dw_post"></span></li>
    <li id="id-3">Total User: <span id="dw_user"></span></li>
    <li id="id-10">Most Online: <span id="dw_online"></span></li>
    </ul>
    <style>.dwtheme li:nth-child(1) {
    background: url("http://i48.servimg.com/u/f48/17/48/49/15/highli19.png") repeat-x scroll 0 0 #EEE;
    border: 1px solid #D8D8D8;
    clear: both;
    margin-left: -6px;
    margin-right: -6px;
    padding: 5px 8px;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
    position: relative;
    top: -6px;
    }

    .dwtheme {
    background: whiteSmoke;
    border: 1px solid #DDD;
    width: 190px;
    padding: 5px;
    margin-left: 10px;
    margin-top: 16px;
    }

    #id-1, #id-2, #id-3, #id-4, #id-5, #id-6, #id-7, #id-8 {
    padding: 0 0 6px;
    border-bottom: 1px solid #CCC;
    margin-bottom: 5px;
    }

    #id-9, #id-10 {
    padding: 0 0;
    margin-bottom: 2px;
    }

    .dwtheme #views {
    float: right;
    }

    div#dw_right {
    display: block;
    }

    #dw_topic, #dw_post, #dw_user, #dw_online {
    padding-left: 5px;
    }

    #latest_online_members a span {
    display: none;
    }

    #latest_online_members a img {
    width: 30px;
    margin-right: 7px;
    height: 30px;
    background: white;
    padding: 1px;
    box-shadow: 0 0 5px rgba(0, 0, 0, 0.13);
    margin-bottom: 5px;
    }

    #latest_online_members a span {
    position: absolute;
    margin-left: -45px;
    margin-top: -20px;
    background: #EEE;
    padding: 2px 5px;
    border: 1px solid;
    }

    #latest_online_members a:hover #latest_online_members a span {
    display: block;
    }

    #latest_online_members {
    margin-left: 14px;
    }

    #toggle_sidebar {
    position: absolute;
    right: 37px;
    z-index: 8000;
    background: #1988C7;
    padding: 3px 7px;
    -webkit-border-radius: 4px;
    -moz-border-radius: 4px;
    border-radius: 4px;
    color: white;
    opacity: 0.1;
    -webkit-transition: all 0.4s ease-in-out;
    -moz-transition: all 0.4s ease-in-out;
    }

    #toggle_sidebar:hover {
    opacity: 1;
    }
    </style></div>');
    });

    $(function() {
    $('#variables strong:eq(0)').clone().appendTo('#dw_topic');
    $('#variables strong:eq(1)').clone().appendTo('#dw_post');
    $('#variables strong:eq(2)').clone().appendTo('#dw_user');
    $('#variables strong:eq(3)').clone().appendTo('#dw_online');
    $('#latest_online_members').load('/memberlist #memberlist .avatar-mini a:lt(8)');
    });

    $(function () {
            $('a.toggle_sidebar2').click(function () {
                  $('#dw_right').css('display', 'none');
                  $('#content-container div#container').css('width', '100%');
            });
            $('#toggle_sidebar').click(function () {
                  $('#dw_right').css('display', 'block');
                  $('#content-container div#container').css('width', '83%');
            });
          });
Desi nu sunt sigur ca va functiona think

Omu
Membru onorific
Membru onorific

masculin

Mesaje : 6310
Varsta : 20
Data de inscriere : 04/11/2010
Multumiri : 153
Niciun avertisment

http://www.tech-titans.net/

Sus In jos

Rezolvat Re: problema conditia if else

Mesaj Scris de VeteraNNN la data de Sam 2 Feb - 8:01

Cod:
$(function () {
            $('a.toggle_sidebar2').click(function () {
                  $('#dw_right').css('display', 'none');
                  $('#content-container div#container').css('width', '100%');
            });
            $('#toggle_sidebar').click(function () {
                  $('#dw_right').css('display', 'block');
                  $('#content-container div#container').css('width', '83%');
            });
          });

acest cod nu va functiona Supărat din cauza asta :
pentru ca ar fi trebuit ceva de genu:
Cod:
var x = document.getTagById("id");
if(x conditie) {
$('#toggle_sidebar').addClass('nume');
            $('#toggle_sidebar.nume').click(function () {
                  $('#dw_right').css('display', 'none');
                  $('#content-container div#container').css('width', '100%');
            });
}
  else {
$('#toggle_sidebar.nume').removeClass('nume').addClass('active');
          $('#toggle_sidebar.active').click(function () {
                  $('#dw_right').css('display', 'block');
                  $('#content-container div#container').css('width', '83%');
            });
}

PS: am facut al cod Fericit dar aceiasi problema Supărat
Cod:
$(function() {
var z=document.getElementById('dw_right');
var c=document.getElementById('container');
});

function dwhide() {
if($(x).length>0) {
x.style.display='none';
c.style.width='100%';
}
if else($(c).length>1) {
x.style.display='inline';
c.style.width='83%';
}
else {
x.style.display='none';
c.style.width='100%';
}
}

VeteraNNN
Membru activ

masculin

Mesaje : 485
Varsta : 22
Localizare : Undeva in spatele tau !!
Data de inscriere : 28/10/2012
Multumiri : 0
Membru exclus

Sus In jos

Rezolvat Re: problema conditia if else

Mesaj Scris de Adi. la data de Sam 2 Feb - 22:01

Topicul a fost marcat ca fiind rezolvat, deci il voi trimite in arhiva.

Adi.
Membru onorific
Membru onorific

masculin

Mesaje : 3749
Localizare : Forumgratuit
Data de inscriere : 01/08/2012
Multumiri : 30
Niciun avertisment

Sus In jos

Vezi subiectul anterior Vezi subiectul urmator Sus

- Subiecte similare

Permisiunile acestui forum:
Nu puteti raspunde la subiectele acestui forum