Skip to main content
título editado
Link
saimita
  • 125
  • 1
  • 13

Jquery remove todas as divs menos selecionada e as do outro mrnumenu

adicionou 3284 caracteres ao conteúdo; título editado
Fonte Link
saimita
  • 125
  • 1
  • 13

Jquery removerremove todas as divs menos a selecionada e as do outro mrnu

Este código remove a divtodas as divs menos selecionada, mas também as do menu motherboard o que eu estava a tentar fazer era ao clicar na div desaparecer todas menos acom que cliqueias debaixo fossem independes das de cima. Peço desculpa por mostrar o código assim mas não dá para meter no editor, porque é preciso dos dados da bd. O resultado deste código https://www.youtube.com/watch?v=kiUECo33-d0https://www.youtube.com/watch?v=wIkAsCj8oIk

<!DOCTYPE html>
<html>
<head>
<title>Configurador</title>
<link href="http://www.jqueryscript.net/css/jquerysctipttop.css" rel="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="css/ResponsiveAccordianMenu.css" rel="stylesheet" type="text/css">
<link href="css/table.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
</head>
<body>
<div class="twd_container">
<h1 style="margin:150px auto 30px auto; text-align:center">Configurar</h1>
 <!--Processador-->
<div id="AL" class="expandContent">
    <h3 class="header">
        <div class="headerColumn1">Processador</div>
        <div class="headerColumn2 expand"><img src="img/plus.png" /></div>
        <div class="expandedContentClearFloat"></div>
    </h3>
    <div class="expandedContent">
        <div class="container">
            <ul id="orders">
            {% for item in processador %}
                <div class="product-removal">
 
                <li>
            <div class="row carousel-row" >

                <div class="col-xs-8 col-xs-offset-2 slide-row" id="container">

                    <div id="carousel-1" class="carousel slide slide-carousel" data-ride="carousel">


                        <!-- Wrapper for slides -->
                        <div class="carousel-inner">
                            <div class="item active">
                                <img class="iconcomp" src="{{ item.img|e }}" alt="Image">
                            </div>

                        </div>
                    </div>
                    <div class="slide-content">
                        <h4>{{ item.marca|e }}</h4>
                        <p>
                            {{ item.descr|e }}
                        </p>
                    </div>
                    <div class="slide-price">
                            <h3> {{ item.preco_unit|e }}€</h3>
                    </div>
 
                    <div class="slide-cima" id="{{ item.id|e }}">
                     <!-- <span class="pull-right buttons">buttons" aria-label="Close">
                         <button class="btn2" id='remove' value='{{ item.id|e }}' onclick="rmv(this)"><i class="fa fa-fw fa-undo"><close"></i></button>
                      </span>-->
                        <button type="button" class="close" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>

                    </div>
 
                    <div class="slide-footer" id="{{ item.id|e }}">
                      <span      <button class="pull-right buttons">remove-product">
                         <button name="" class="btn1" id='item' value='{{ item.id|e }}' ><i<i class="fa fa-fw fa-shopping-cart"></i></button>
                      </span>
                            <button class="remove-product">
                                Removei>
                            </button>
                    </div>
 
                </div>

            </div>
                </li>
                </div>

                {% endfor %}
            </ul>
        </div>
    </div>
</div>
<div class="clearfloat"></div>


<!--Motherboard-->
<div id="NH" class="expandContent">
    <h3 class="header">
        <div class="headerColumn1">Motherboard</div>
        <div class="headerColumn2 expand"><img src="img/plus.png" /></div>
        <div class="expandedContentClearFloat"></div>
    </h3>
    <div class="expandedContent">
        <div class="container">
            {% for item in motherboard %}
            <div class="row carousel-row" >

                <div class="col-xs-8 col-xs-offset-2 slide-row" id="container">

                    <div id="carousel-1" class="carousel slide slide-carousel" data-ride="carousel">


                        <!-- Wrapper for slides -->
                        <div class="carousel-inner">
                            <div class="item active">
                                <img class="iconcomp" src="{{ item.img|e }}" alt="Image">
                            </div>

                        </div>
                    </div>
                    <div class="slide-content">
                        <h4>{{ item.marca|e }}</h4>
                        <p>
                            {{ item.descr|e }}
                        </p>
                    </div>
                    <div class="slide-price">
                            <h3> {{ item.preco_unit|e }}€</h3>
                    </div>

                    <div class="slide-cima" id="{{ item.id|e }}">
                     <!-- <span class="pull-right buttons" aria-label="Close">
                         <button class="btn2" id='remove' value='{{ item.id|e }}' onclick="rmv(this)"><i class="fa fa-fw close"></i></button>
                      </span>-->
                        <button type="button" class="close" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>

                    </div>

                    <div class="slide-footer" id="{{ item.id|e }}">
                            <button class="pull-right remove-product">
                                <i class="fa fa-fw fa-shopping-cart"></i>
                            </button>
                    </div>
                </div>

            </div>
            {% endfor %}

        </div>
    </div>
</div>
<div class="clearfloat"></div>
</div>

   <!-- scripts-->
   <script type="text/javascript">
   $('.product-removalclose').hide();
 button'  $('.remove-product').click( function() {
    var allExceptClicked = $('.remove-product').not(this);
    removeItem(allExceptClicked);
   });
   $('.close').click( function() {
    var allExceptClicked = $('.close').not(this);
    addItem(allExceptClicked);
    });
    function addItem(addButton)
    {
    $('.remove-product').show();
    $('.close').hide();
    var productRow = $(addButton).parent().parent();
    productRow.show();
    }
    function removeItem(removeButton)
   {
    $('.remove-product').hide();
    $('.close').show();
    var productRow = $(removeButton).parent().parent();
        productRow.removehide();
  }
 
  </script>
  <script
    src="https://code.jquery.com/jquery-3.3.1.min.js"
    integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
    crossorigin="anonymous"></script>
<script src="js/ResponsiveAccordianMenu.js"></script>
</body>
</html>

Jquery remover todas as divs menos a selecionada

Este código remove a div selecionada, o que eu estava a tentar fazer era ao clicar na div desaparecer todas menos a que cliquei. Peço desculpa por mostrar o código assim mas não dá para meter no editor, porque é preciso dos dados da bd. O resultado deste código https://www.youtube.com/watch?v=kiUECo33-d0

<!DOCTYPE html>
<html>
<head>
<title>Configurador</title>
<link href="http://www.jqueryscript.net/css/jquerysctipttop.css" rel="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="css/ResponsiveAccordianMenu.css" rel="stylesheet" type="text/css">
<link href="css/table.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
</head>
<body>
<div class="twd_container">
<h1 style="margin:150px auto 30px auto; text-align:center">Configurar</h1>
<!--Processador-->
<div id="AL" class="expandContent">
    <h3 class="header">
        <div class="headerColumn1">Processador</div>
        <div class="headerColumn2 expand"><img src="img/plus.png" /></div>
        <div class="expandedContentClearFloat"></div>
    </h3>
    <div class="expandedContent">
        <div class="container">
            <ul id="orders">
            {% for item in processador %}
                <div class="product-removal">
                <li>
            <div class="row carousel-row" >

                <div class="col-xs-8 col-xs-offset-2 slide-row" id="container">

                    <div id="carousel-1" class="carousel slide slide-carousel" data-ride="carousel">


                        <!-- Wrapper for slides -->
                        <div class="carousel-inner">
                            <div class="item active">
                                <img class="iconcomp" src="{{ item.img|e }}" alt="Image">
                            </div>

                        </div>
                    </div>
                    <div class="slide-content">
                        <h4>{{ item.marca|e }}</h4>
                        <p>
                            {{ item.descr|e }}
                        </p>
                    </div>
                    <div class="slide-cima" id="{{ item.id|e }}">
                      <span class="pull-right buttons">
                         <button class="btn2" id='remove' value='{{ item.id|e }}' onclick="rmv(this)"><i class="fa fa-fw fa-undo"></i></button>
                      </span>

                    </div>
                    <div class="slide-footer" id="{{ item.id|e }}">
                      <span class="pull-right buttons">
                         <button name="" class="btn1" id='item' value='{{ item.id|e }}' ><i class="fa fa-fw fa-shopping-cart"></i></button>
                      </span>
                            <button class="remove-product">
                                Remove
                            </button>
                    </div>
                </div>

            </div>
                </li>
                </div>

                {% endfor %}
            </ul>
        </div>
    </div>
</div>
<div class="clearfloat"></div>
</div>

<!-- scripts-->
 <script type="text/javascript">
$('.product-removal button').click( function() {
   removeItem(this);
});
function removeItem(removeButton)
{
    var productRow = $(removeButton).parent().parent();
        productRow.remove();
}
 
</script>
<script
    src="https://code.jquery.com/jquery-3.3.1.min.js"
    integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
    crossorigin="anonymous"></script>
<script src="js/ResponsiveAccordianMenu.js"></script>
</body>
</html>

Jquery remove todas as divs menos selecionada e as do outro mrnu

Este código remove todas as divs menos selecionada, mas também as do menu motherboard o que eu estava a tentar fazer era com que as debaixo fossem independes das de cima. Peço desculpa por mostrar o código assim mas não dá para meter no editor, porque é preciso dos dados da bd. O resultado deste código https://www.youtube.com/watch?v=wIkAsCj8oIk

<!DOCTYPE html>
<html>
<head>
<title>Configurador</title>
<link href="http://www.jqueryscript.net/css/jquerysctipttop.css" rel="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="css/ResponsiveAccordianMenu.css" rel="stylesheet" type="text/css">
<link href="css/table.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
</head>
<body>
<div class="twd_container">
<h1 style="margin:150px auto 30px auto; text-align:center">Configurar</h1>
 <!--Processador-->
<div id="AL" class="expandContent">
    <h3 class="header">
        <div class="headerColumn1">Processador</div>
        <div class="headerColumn2 expand"><img src="img/plus.png" /></div>
        <div class="expandedContentClearFloat"></div>
    </h3>
    <div class="expandedContent">
        <div class="container">
            <ul id="orders">
            {% for item in processador %}
                <div class="product-removal">
 
                <li>
            <div class="row carousel-row" >

                <div class="col-xs-8 col-xs-offset-2 slide-row" id="container">

                    <div id="carousel-1" class="carousel slide slide-carousel" data-ride="carousel">


                        <!-- Wrapper for slides -->
                        <div class="carousel-inner">
                            <div class="item active">
                                <img class="iconcomp" src="{{ item.img|e }}" alt="Image">
                            </div>

                        </div>
                    </div>
                    <div class="slide-content">
                        <h4>{{ item.marca|e }}</h4>
                        <p>
                            {{ item.descr|e }}
                        </p>
                    </div>
                    <div class="slide-price">
                            <h3> {{ item.preco_unit|e }}€</h3>
                    </div>
 
                    <div class="slide-cima" id="{{ item.id|e }}">
                     <!-- <span class="pull-right buttons" aria-label="Close">
                         <button class="btn2" id='remove' value='{{ item.id|e }}' onclick="rmv(this)"><i class="fa fa-fw close"></i></button>
                      </span>-->
                        <button type="button" class="close" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>

                    </div>
 
                    <div class="slide-footer" id="{{ item.id|e }}">
                            <button class="pull-right remove-product">
                                <i class="fa fa-fw fa-shopping-cart"></i>
                            </button>
                    </div>
 
                </div>

            </div>
                </li>
                </div>

                {% endfor %}
            </ul>
        </div>
    </div>
</div>
<div class="clearfloat"></div>


<!--Motherboard-->
<div id="NH" class="expandContent">
    <h3 class="header">
        <div class="headerColumn1">Motherboard</div>
        <div class="headerColumn2 expand"><img src="img/plus.png" /></div>
        <div class="expandedContentClearFloat"></div>
    </h3>
    <div class="expandedContent">
        <div class="container">
            {% for item in motherboard %}
            <div class="row carousel-row" >

                <div class="col-xs-8 col-xs-offset-2 slide-row" id="container">

                    <div id="carousel-1" class="carousel slide slide-carousel" data-ride="carousel">


                        <!-- Wrapper for slides -->
                        <div class="carousel-inner">
                            <div class="item active">
                                <img class="iconcomp" src="{{ item.img|e }}" alt="Image">
                            </div>

                        </div>
                    </div>
                    <div class="slide-content">
                        <h4>{{ item.marca|e }}</h4>
                        <p>
                            {{ item.descr|e }}
                        </p>
                    </div>
                    <div class="slide-price">
                            <h3> {{ item.preco_unit|e }}€</h3>
                    </div>

                    <div class="slide-cima" id="{{ item.id|e }}">
                     <!-- <span class="pull-right buttons" aria-label="Close">
                         <button class="btn2" id='remove' value='{{ item.id|e }}' onclick="rmv(this)"><i class="fa fa-fw close"></i></button>
                      </span>-->
                        <button type="button" class="close" aria-label="Close">
                            <span aria-hidden="true">&times;</span>
                        </button>

                    </div>

                    <div class="slide-footer" id="{{ item.id|e }}">
                            <button class="pull-right remove-product">
                                <i class="fa fa-fw fa-shopping-cart"></i>
                            </button>
                    </div>
                </div>

            </div>
            {% endfor %}

        </div>
    </div>
</div>
<div class="clearfloat"></div>
</div>

   <!-- scripts-->
   <script type="text/javascript">
   $('.close').hide();
   $('.remove-product').click( function() {
    var allExceptClicked = $('.remove-product').not(this);
    removeItem(allExceptClicked);
   });
   $('.close').click( function() {
    var allExceptClicked = $('.close').not(this);
    addItem(allExceptClicked);
    });
    function addItem(addButton)
    {
    $('.remove-product').show();
    $('.close').hide();
    var productRow = $(addButton).parent().parent();
    productRow.show();
    }
    function removeItem(removeButton)
   {
    $('.remove-product').hide();
    $('.close').show();
    var productRow = $(removeButton).parent().parent();
    productRow.hide();
  }
  </script>
  <script
    src="https://code.jquery.com/jquery-3.3.1.min.js"
    integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
    crossorigin="anonymous"></script>
<script src="js/ResponsiveAccordianMenu.js"></script>
</body>
</html>
Fonte Link
saimita
  • 125
  • 1
  • 13

Jquery remover todas as divs menos a selecionada

Este código remove a div selecionada, o que eu estava a tentar fazer era ao clicar na div desaparecer todas menos a que cliquei. Peço desculpa por mostrar o código assim mas não dá para meter no editor, porque é preciso dos dados da bd. O resultado deste código https://www.youtube.com/watch?v=kiUECo33-d0

<!DOCTYPE html>
<html>
<head>
<title>Configurador</title>
<link href="http://www.jqueryscript.net/css/jquerysctipttop.css" rel="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href="css/ResponsiveAccordianMenu.css" rel="stylesheet" type="text/css">
<link href="css/table.css" rel="stylesheet" type="text/css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
</head>
<body>
<div class="twd_container">
<h1 style="margin:150px auto 30px auto; text-align:center">Configurar</h1>
<!--Processador-->
<div id="AL" class="expandContent">
    <h3 class="header">
        <div class="headerColumn1">Processador</div>
        <div class="headerColumn2 expand"><img src="img/plus.png" /></div>
        <div class="expandedContentClearFloat"></div>
    </h3>
    <div class="expandedContent">
        <div class="container">
            <ul id="orders">
            {% for item in processador %}
                <div class="product-removal">
                <li>
            <div class="row carousel-row" >

                <div class="col-xs-8 col-xs-offset-2 slide-row" id="container">

                    <div id="carousel-1" class="carousel slide slide-carousel" data-ride="carousel">


                        <!-- Wrapper for slides -->
                        <div class="carousel-inner">
                            <div class="item active">
                                <img class="iconcomp" src="{{ item.img|e }}" alt="Image">
                            </div>

                        </div>
                    </div>
                    <div class="slide-content">
                        <h4>{{ item.marca|e }}</h4>
                        <p>
                            {{ item.descr|e }}
                        </p>
                    </div>
                    <div class="slide-cima" id="{{ item.id|e }}">
                      <span class="pull-right buttons">
                         <button class="btn2" id='remove' value='{{ item.id|e }}' onclick="rmv(this)"><i class="fa fa-fw fa-undo"></i></button>
                      </span>

                    </div>
                    <div class="slide-footer" id="{{ item.id|e }}">
                      <span class="pull-right buttons">
                         <button name="" class="btn1" id='item' value='{{ item.id|e }}' ><i class="fa fa-fw fa-shopping-cart"></i></button>
                      </span>
                            <button class="remove-product">
                                Remove
                            </button>
                    </div>
                </div>

            </div>
                </li>
                </div>

                {% endfor %}
            </ul>
        </div>
    </div>
</div>
<div class="clearfloat"></div>
</div>

<!-- scripts-->
 <script type="text/javascript">
$('.product-removal button').click( function() {
   removeItem(this);
});
function removeItem(removeButton)
{
    var productRow = $(removeButton).parent().parent();
        productRow.remove();
}

</script>
<script
    src="https://code.jquery.com/jquery-3.3.1.min.js"
    integrity="sha256-FgpCb/KJQlLNfOu91ta32o/NMZxltwRo8QtmkMRdAu8="
    crossorigin="anonymous"></script>
<script src="js/ResponsiveAccordianMenu.js"></script>
</body>
</html>