Search code examples
jqueryslidetoggle

jQuery two divs with same slideToggle but different behaviour


I have a page with these tabs.

First part is Buyer information and second is Deposit List. As you can see in jsFiddle link I want Buyer information go up like Deposit List, but it does not.

$(document).ready(function() {
  $(".hotel_related_to").each(function() {
    $(this).click(function() {
      $(this).closest(".form_tbl").next(".buyer").slideToggle()
    });
  });
});


$(document).ready(function() {
  $(".hotel_related_to").each(function() {
    $(this).click(function() {
      $(this).closest(".form_tbl").next(".invoice_info_resize", ".rTable").slideToggle()
    });
  });
});
@font-face {
  font-family: "IRANSansWeb";
  font-style: normal;
  font-weight: bold;
  src: url("../_fonts/IRANSansWeb.eot?#iefix") format("embedded-opentype"), url("../_fonts/IRANSansWeb.woff") format("woff"), url("../_fonts/IRANSansWeb.ttf") format("truetype");
}

@font-face {
  font-family: 'FontAwesome';
  src: url('../_fonts/fontawesome-webfont.eot');
  src: url('../_fonts/fontawesome-webfont.eot') format('embedded-opentype'), url('../_fonts/fontawesome-webfont.woff2') format('woff2'), url('../_fonts/fontawesome-webfont.woff') format('woff'), url('../_fonts/fontawesome-webfont.ttf') format('truetype'), url('../_fonts/fontawesome-webfont.svg') format('svg');
  font-weight: normal;
  font-style: normal;
}

body {
  font-size: 11px;
  background-color: #eff1f2;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: 'IRANSansWeb';
}

.fa-barcode::before {
  font-family: 'FontAwesome';
  content: "\f02a";
  margin-right: 1%;
}

.fa-calendar-check-o::before {
  font-family: 'FontAwesome';
  content: "\f274";
  margin-right: 1%;
}

.fa-plane::before {
  font-family: 'FontAwesome';
  content: "\f072";
  margin-right: 1%;
}

.fa-group::before,
.fa-users::before {
  font-family: 'FontAwesome';
  content: "\f0c0";
  margin-right: 1%;
}

.fa-reply-all::before {
  font-family: 'FontAwesome';
  content: '\f122 ';
}

.fa-floppy-o::before {
  font-family: 'FontAwesome';
  content: '\f0c7';
}

.clr {
  clear: both;
  margin: 0 auto;
}

.box {
  width: 100%;
}

.body_box {
  box-sizing: border-box;
  margin-bottom: 100px;
  width: 1200px;
  margin: 0 auto;
}

.box2 {
  width: 100%;
  background: #fff;
  min-height: 100px;
  border-radius: 3px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
  border: 1px solid #d3d8db;
  margin-top: 20px;
  direction: rtl;
  text-align: right;
}

#etebar {
  margin-top: 174px;
}

.title_tbl {
  float: right;
  direction: rtl;
  width: 100%;
}

.title2 {
  font-size: 20px;
  color: #6a7489;
}

.top_msg {
  color: #6a7489;
}

.title_tbl td:nth-child(2) {
  padding-right: 10px;
}

.box1_1 {
  width: 100%;
  background: #fff;
  border-radius: 3px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
  border: 1px solid #d3d8db;
  min-height: 80px;
  position: relative;
  margin-bottom: 20px;
}

.box1_1 table {
  direction: rtl;
  float: right;
  width: 100%;
  padding: 26px;
}

.box1_1 table i {
  color: #ff9000;
  padding-left: 10px;
}

.box1_comment {
  width: 100%;
  margin-bottom: 20px;
  background: #fff;
  border-radius: 3px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
  border: 1px solid #d3d8db;
  min-height: 320px;
  position: relative;
  margin-bottom: 20px;
}

.form_tbl {
  direction: rtl;
  width: 100%;
  padding: 20px;
}

.invoice_tbl_header {
  padding-bottom: 0 !important;
}

.form_invoice {
  padding: 10px !important;
  padding-bottom: 10px;
  border-spacing: 0;
}

.form_tbl tr td:nth-child(1) {
  color: #4d4d4d !important;
}

.form_invoice tr:nth-child(2n+1) td {
  background: #f4f8fb;
  border-bottom: 1px solid #d7e3ed;
  padding-right: 10px;
}

.form_tbl tr td:first-child {
  color: #313131;
  font-size: 13px;
  font-family: 'IRANSansWeb';
}

.form_tbl tr td:second-child {
  color: #313131;
  font-size: 13px;
  font-family: 'IRANSansWeb';
}

.form_tbl td {
  padding: 10px 0;
  padding-right: 0px;
}

.hotel_related_to {
  background: url(../images/dotted.png) repeat-x center !important;
}

.hotel_related {
  background: url(../images/dotted.png) repeat-x center !important;
}

.hotel_related_to_country {
  padding: 5px 10px;
  background: #fff8ee;
  border: 1px solid #e7bf85;
  border-radius: 5px;
  display: inline-block;
  cursor: pointer;
}

.buy {
  padding: 13px;
  float: right;
  clear: both;
  direction: rtl;
  font-size: 12px;
}

.invoice_info {
  margin: 20px;
}

ul.resp-tabs-list,
p {
  margin: 0px;
  padding: 0px;
}

ul.resp-tabs-list {
  display: table;
  width: 99.9%;
  position: relative;
  bottom: -1px;
  font-size: 10px;
}

.product-collateral .resp-tabs-list li {
  padding: 8px 25px;
  border: 1px solid #000;
  list-style: none;
  cursor: pointer;
  line-height: 32px;
  float: right;
  font-size: 133.33%;
  color: white;
  font-weight: 500;
  text-transform: uppercase;
  margin: -2px 0 0 -1px;
  transition: 0.1s ease-in-out;
  -webkit-transition: 0.1s ease-in-out;
  -moz-transition: 0.1s ease-in-out;
  -o-transition: 0.1s ease-in-out;
  -ms-transition: 0.1s ease-in-out;
  background-color: #4d576e;
}

.product-collateral .resp-tabs-list li:hover {
  background: #000;
  border-color: #000;
  border-left-color: #000;
  color: #fff;
}

.tab-related-up-sell .resp-tabs-container .resp-tab-content {
  padding: 0;
}

.resp-tabs-container {
  padding: 0px;
  clear: left;
}

.resp-tabs-container .resp-tab-content {
  border: 1px solid #eaeaea;
  min-height: 722px;
}

.resp-tabs-container .std {
  margin-bottom: -10px;
}

.resp-tabs-container .std ul {
  list-style: none;
}

.resp-tabs-container .std ul li:before {
  content: '\f00c';
  display: inline-block;
  font-family: FontAwesome;
  font-style: normal;
  font-weight: normal;
  font-variant: normal;
  font-synthesis: weight style;
  font-stretch: normal;
  font-size-adjust: none;
  font-language-override: normal;
  font-kerning: auto;
  font-feature-settings: normal;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  font-size: 13px;
  color: #000;
  margin-right: 5px;
}

h2.resp-accordion {
  cursor: pointer;
  padding: 5px;
  display: none;
}

.resp-tab-content {
  display: none;
  color: #666;
}

.product-collateral .resp-tabs-list .resp-tab-active {
  color: #fff;
  text-transform: uppercase;
  background: #555;
  border-color: #555;
}

.resp-content-active,
.resp-accordion-active {
  display: block;
}

h2.resp-accordion {
  font-size: 108.33%;
  text-transform: uppercase;
  border: 1px solid #eaeaea;
  margin-top: -1px;
  padding: 10px 15px;
}

h2.resp-tab-active {
  border-bottom: 0px solid #eaeaea !important;
  margin-bottom: 0px !important;
  padding: 10px 15px !important;
}

.resp-vtabs ul.resp-tabs-list {
  float: left;
  width: 30%;
}

.resp-vtabs .resp-tabs-list li {
  display: block;
  padding: 15px 15px !important;
  margin: 0;
  cursor: pointer;
  float: none;
}

.resp-vtabs .resp-tabs-container {
  padding: 0px;
  background-color: #fff;
  border: 1px solid #eaeaea;
  float: left;
  width: 68%;
  min-height: 250px;
  border-radius: 4px;
  clear: none;
}

.resp-vtabs .resp-tab-content {
  border: none;
}

.resp-vtabs li.resp-tab-active {
  border: 1px solid #eaeaea;
  border-right: none;
  background-color: #fff;
  position: relative;
  z-index: 1;
  margin-right: -1px !important;
  padding: 14px 15px 15px 14px !important;
}

h2.resp-tab-active span.resp-arrow {
  border: none;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 12px solid #555;
  float: left;
}

.resp-easy-accordion h2.resp-accordion {
  display: block;
}

.box2-1 {
  width: 100% !important;
  float: right;
  background: #fff;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
  position: relative;
  padding-bottom: 20px;
}

@media only screen and (max-width: 768px) {
  ul.resp-tabs-list {
    display: none;
  }
  h2.resp-accordion {
    display: block;
    text-align: right;
    background-color: #4d576e;
    border: 1px solid black;
    color: #fff
  }
  h2.resp-tab-active {
    background-color: #555
  }
  .resp-vtabs .resp-tab-content {
    border: 1px solid #fff;
  }
  .product-collateral .resp-tabs-list li:hover {
    background: #000;
    border-color: #000;
    border-left-color: #000;
    color: #fff;
  }
  .resp-vtabs .resp-tabs-container {
    border: none;
    float: none;
    width: 100%;
    min-height: initial;
    clear: none;
  }
  .resp-accordion-closed {
    display: none !important;
  }
  .resp-vtabs .resp-tab-content:last-child {
    border-bottom: 1px solid #fff !important;
  }
}

.tab-product-info {
  margin-top: 2%;
  margin-right: 2%;
}

.save_form {
  color: #363A41;
  background-color: #fff;
  border: 1px solid #DEDEDE;
  display: inline-block;
  font-weight: normal;
  text-align: center;
  font-size: 12px;
  cursor: pointer;
  background: #fff;
  border: 1px solid DEDEDE;
  line-height: 1.3;
  border-radius: 3px;
  margin-top: 15px;
  font-family: 'IRANSansWeb';
  height: 56px;
  float: left;
  margin-right: 5px;
  margin-left: 10px;
}

.save_form i {
  font-size: 25px;
  display: block;
}

a {
  text-decoration: none;
}

.invoice_info_resize p {
  padding: 10px;
  float: right;
  clear: both;
  direction: rtl;
}

.invoice_tbody tr:first-child td {
  background: #dde8f0;
  border-bottom: 1px solid #cfdee8;
}

.save_form:hover {
  color: #fff;
  background: #ff9000;
}

.tab {
  width: 70%;
  float: right
}

.fix {
  width: 30%;
}

.row1_container {
  width: 100%;
  float: left;
  padding-right: 5%;
}

.row .row1 {
  width: 100% !important;
}

.row .row1 {
  width: 30%;
  float: left;
  background-color: #EBEBEB;
  border: 1px solid #e6e6e6;
  border-radius: 5px;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.1), 0 0 0 3px #fff inset;
  margin-bottom: 20px;
  padding: 20px;
  position: relative;
}

.headerrow {
  border-bottom: 1px solid #B8B8B8;
  float: right;
}

.fa-file-text::before {
  content: "\f15c";
  font-size: 15px;
  font-family: FontAwesome;
  font-style: normal;
  font-weight: normal;
  margin: 0 4px;
}

.table {
  background-color: #fff;
  border: 1px solid #ccc;
  padding: 0;
  border-radius: 3px;
  -moz-border-radius: 3px;
  -webkit-border-radius: 3px;
}

.table tr td {
  border-bottom: 1px solid #dadbdb;
  color: #333;
  font-size: 10px;
  padding: 4px 6px 4px 6px;
}

form {
  margin: 0;
}

.desc_btn1 {
  float: right;
  margin: 10px 5px;
}

widget button {
  font-family: Trebuchet MS, Tahoma, Verdana, Arial, sans-serif;
  font-size: 1em;
}

.btn {
  -moz-user-select: none;
  background-image: none;
  border: 1px solid #CACACA;
  border-radius: 3px;
  cursor: pointer;
  display: inline-block;
  font-size: 10px;
  font-weight: normal;
  line-height: 1.42857;
  margin-bottom: 0;
  padding: 4px 8px;
  text-align: center;
  vertical-align: middle;
  white-space: nowrap;
  background-color: #fff;
}

.btn:hover {
  color: #fff;
  background: #ff9000;
}

.select_condition_td {
  width: 45%
}

.description {
  width: 55%
}

button,
select {
  text-transform: none;
}

.icon-save::before {
  color: #555;
  content: "\f0c7";
  font-family: FontAwesome;
}

.desc_btn2 {
  float: right;
  margin: 10px 5px;
}

.icon-save::before {
  color: #555;
  content: "\f0c7";
  font-family: FontAwesome;
}

.fa-floppy-o::before {
  font-family: FontAwesome;
  content: "\f0c7";
}

.table {
  background-color: #fff;
  border: 1px solid #ccc;
  padding: 0;
  border-radius: 3px;
  -moz-border-radius: 3px;
  -webkit-border-radius: 3px;
}

.table tr th {
  background-color: #F1F1F1;
  text-shadow: 0 1px 0 #fff;
  padding: 4px 6px;
  font-size: 10px;
  color: #333;
  border-bottom: solid 1px #ccc;
}

.center {
  text-align: center;
}

.condition_tbl {
  width: 100%;
  margin-top: 10px;
}

.condition_tbl select {
  width: 100%;
  position: relative;
  top: -14px;
  padding: 4px 0;
  font-size: 10px;
  text-align: center;
}

.Condition_desc {
  background-color: #fff;
  background-image: none;
  border: 1px solid #ccc;
  border-radius: 3px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
  color: #555;
  display: block;
  font-size: 10px;
  height: 61px;
  line-height: 1.42857;
  padding: 2% 2%;
  transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s;
  width: 96% !important;
}

.condition_tbl select option {
  width: 100%;
  padding: 1px 0;
  font-size: 10px;
}

.textarea-autosize {
  background-color: #fff;
  background-image: none;
  border: 1px solid #ccc;
  border-radius: 3px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.075) inset;
  color: #555;
  display: block;
  font-size: 10px;
  height: 61px;
  line-height: 1.42857;
  padding: 2% 2%;
  transition: border-color 0.15s ease-in-out 0s, box-shadow 0.15s ease-in-out 0s;
  width: 100% !important;
  margin: 10px 0;
  overflow: auto;
  vertical-align: top !important;
}

.row_hover {
  background-color: #f7f7f7;
}

.fa-user::before {
  content: "\f007";
  font-family: FontAwesome;
  font-style: normal;
  font-weight: normal;
  font-size: 15px;
  margin: 0 4px;
}

.fa-credit-card::before {
  content: "\f155";
  font-size: 15px;
  font-family: FontAwesome;
  font-style: normal;
  font-weight: normal;
  margin: 0 4px;
}

.title_tbl tr td:first-child {
  width: 100px;
}

.rTable {
  display: none;
  margin-left: 35%;
  text-align: center;
}

.rTableRow {
  display: table-row;
}

.rTableCell,
.rTableHead {
  display: table-cell;
  padding: 3px 10px;
  border: 1px solid #999999;
  width: 100%
}

.rTableCell {
  background-color: #f4f8fb;
}

.rTableHead {
  background-color: #dde8f0;
}

.save-i {
  float: right
}

.saves {
  float: right;
}

.hotel_related {
  display: none;
}

.box-cost {
  direction: rtl;
  width: 50%;
  font-size: 13px;
  padding: 13px 120px;
  float: right;
  margin-top: 24px;
}

.box1-cost {
  direction: ltr;
  width: 50%;
  font-size: 13px;
  padding: 10px 120px;
  float: left;
  margin-top: 24px;
}

.cost {
  font-family: 'IRANSansWeb';
  width: 50%
}

.cost1 {
  font-family: 'IRANSansWeb';
  width: 50%
}

.line {
  border-bottom: 1px solid #dddbdb;
  padding: 2px 0;
}

.header {
  width: 100%;
  min-height: 100px;
}

.mali {
  width: 100%
}

.box-m {
  width: 100%;
  margin-bottom: 20px;
  background: #fff;
  border-radius: 3px;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.05);
  border: 1px solid #d3d8db;
  min-height: 100px;
  position: relative;
  margin-bottom: 20px;
}

@media only screen and (max-width:1200px) {
  .body_box {
    width: 100%;
    padding: 0px 10px
  }
}

@media only screen and (max-width: 1169px) {
  .desc_btn1 {
    width: 100%;
    margin: 5px 1px;
  }
  .desc_btn2 {
    width: 100%;
    margin: 5px 1px;
  }
  .btn {
    width: 100%;
  }
  .condition_tbl select {
    font-size: 9px;
  }
}

@media only screen and (max-width:1085px) {
  .description {
    width: 50%;
  }
  .select_condition_td {
    width: 50%;
  }
}

@media only screen and (max-width:1070px) {
  .fix {
    width: 100%;
  }
  .tab {
    width: 100%;
    float: right;
  }
  .btn {
    width: 100%;
  }
  .row1_container {
    padding-right: 8%;
    margin: 3%;
  }
  .desc_btn1 {
    width: 50%;
    margin: 5px 1px;
    float: right
  }
  .desc_btn2 {
    width: 49%;
    margin: 5px 1px;
    float: left
  }
  .btn {
    width: 100%;
  }
  .condition_tbl select {
    font-size: 9px;
  }
  .save-i {
    width: 20%;
    float: right
  }
  .saves {
    width: 20%;
    float: right;
    margin-top: -2%;
  }
}

@media only screen and (max-width:844px) {
  .tr-respans {
    font-size: 10px;
  }
}

@media only screen and (max-width:1110px) {
  .box-cost {
    padding: 13px 100px;
  }
}

@media only screen and (max-width:786px) {
  .box1-cost {
    padding: 13px 100px;
  }
}

@media only screen and (max-width:706px) {
  .box1-cost {
    padding: 13px 40px;
  }
  .box-cost {
    padding: 13px 40px;
  }
}

@media only screen and (min-width:700px) {
  .rTable {
    display: none!important;
    margin: 3%
  }
  @media only screen and (min-width:1070px) {}
  .invoice_info_resize {
    display: block;
  }
  .hotel_related {
    display: none!important;
  }
  .hotel_related_to {
    display: block;
  }
}

@media only screen and (max-width:699px) {
  .rTable {
    display: block;
    margin: 3%
  }
  .invoice_info_resize {
    display: none !important;
  }
  .hotel_related {
    display: block;
  }
  .hotel_related_to {
    display: none !important;
  }
}

@media only screen and (max-width:570px) {
  .title2 {
    font-size: 12px;
  }
}

@media only screen and (max-width:585px) {
  .box1_1 {
    min-height: 100px;
  }
  .box1_1 table {
    padding: 0
  }
  .res-td {
    width: 100%;
    float: right;
  }
}

@media only screen and (max-width:513px) {
  .desc_btn1 {
    width: 100%;
    margin: 5px 1px;
  }
  .desc_btn2 {
    width: 100%;
    margin: 5px 1px;
  }
}

@media only screen and (max-width:482px) {
  .save_form {
    font-size: 9px;
  }
}

@media only screen and (max-width:485px) {
  #save {
    width: 10%;
  }
}

@media only screen and (max-width:482px) {
  .box-cost {
    padding: 0px 40px;
    width: 100%;
  }
  .box1-cost {
    padding: 0px 40px;
    width: 100%;
    direction: rtl;
  }
}

@media only screen and (max-width:646px) {
  .save_form {
    line-height: 1;
  }
}

@media only screen and (max-width:400px) {
  .save_form {
    position: absolute;
    margin-right: -71px;
    margin-top: 30px;
  }
  .box2 {
    min-height: 138px;
  }
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="box1 box1_comment">
  <form action="/route/editsave.bc?id=5872286750428c1bf254992e" method="post" class="form_send">
    <table class="form_tbl form_invoice invoice_tbl_header">
      <tbody class="invoice_theader">
          <tr>
            <td colspan="7" class="hotel_related_to">
              <div class="hotel_related_to_country">Buyer information</div>
            </td>
            <td colspan="6" class="hotel_related">
              <div class="hotel_related_to_country">Buyer information</div>
            </td>
          </tr>
        </tbody>
      </table>
      <div class="buyer">
        <table class="form_tbl form_invoice invoice_tbl_body hotel_invoice_body">
          <div class="buy">
            <div class="invoice_info" style="display: block;">
              <span>Buyer:</span>
              <span class="m-buy">jack</span></div>
            <div class="invoice_info" style="display: block;">
              <span>Acount number:</span>
              <span class="m-buy">1111111111</span></div>
            <div class="invoice_info" style="display: block;">
              <span>Account type:</span>
              <span class="m-buy">Normal</span></div>
            <div class="invoice_info" style="display: block;">
              <span>Credit:</span>
              <span class="m-buy">100</span></div>
          </div>
          <button type="submit" name="submitAddproduct" class="save_form save_form1 submit_form" id="etebar">Ad Credit</button>
        </table>
      </div>
    </form>
  </div>
  <div class="box2-1">
    <form action="/route/editsave.bc?id=5872286750428c1bf254992e" method="post" class="form_send">
      <table class="form_tbl form_invoice invoice_tbl_header">
        <tbody class="invoice_theader">
          <tr>
            <td colspan="7" class="hotel_related_to">
              <div class="hotel_related_to_country">Deposit list</div>
            </td>
            <td colspan="6" class="hotel_related">
              <div class="hotel_related_to_country">Deposit list</div>
            </td>
          </tr>

        </tbody>
      </table>
      <div class="invoice_info_resize" style="display: block;">
        <table class="form_tbl form_invoice invoice_tbl_body hotel_invoice_body">
          <thead>
            <tr>
              <td>Number</td>
              <td>Date</td>
              <td>Value</td>
              <td>Type</td>
              <td>Desciption</td>
              <td>Confirmer</td>
            </tr>
          </thead>
          <tbody class="invoice_tbody ">
            <tr>
              <td>123</td>
              <td>2005-10-04</td>
              <td>300</td>
              <td>Cash</td>
              <td>test</td>
              <td>Joe</td>
            </tr>
          </tbody>
        </table>
      </div>
      <div class="rTable">
        <div class="rTableRow">
          <div class="rTableCell">123</div>
          <div class="rTableHead">Number</div>
        </div>
        <div class="rTableRow">
          <div class="rTableCell">1398-10-04</div>
          <div class="rTableHead">Date</div>
        </div>
        <div class="rTableRow">
          <div class="rTableCell"> 20000000</div>
          <div class="rTableHead"></div>
        </div>
        <div class="rTableRow">
          <div class="rTableCell">cash</div>
          <div class="rTableHead">Type</div>
        </div>
        <div class="rTableRow">
          <div class="rTableCell">Desciption</div>
          <div class="rTableHead">test</div>
        </div>
        <div class="rTableRow">
          <div class="rTableCell">Joe</div>
          <div class="rTableHead">Confirmer</div>
        </div>
      </div>
    </form>
 </div>

What's the problem? should I add another div or table around first part? Is Something missing?

https://jsfiddle.net/hamed_gibago/4rxedwdk/2/


Solution

  • Updated https://jsfiddle.net/4rxedwdk/3/

    There is min-height added on box1_comment class. You should remove min-hight.

        .box1_comment {
            width: 100 % ;
            margin - bottom: 20 px;
            background: #fff;
            border - radius: 3 px;
            box - shadow: 0 1 px 1 px rgba(0, 0, 0, 0.05);
            border: 1 px solid# d3d8db;
            /* min - height: 320 px; Remove This */
            position: relative;
            margin - bottom: 20 px;
        }