css - javascript fires if both div have one same class -
suppose, have 2 div 'menu' & 'pipe'. when click menu pipe's width 100% here have 6 pair same affecting 1 affect all. "main code given bellow." here want js this,
addclass 'addwidth' in pipe div pipe div have 1 same class form object(here, menu div) form click event happen,
eg. menu 1 div clicked pipe 1 div have affected.
.hasclass can in way dont know how.
help me it's js,thanks in advance.
.leftbox{ width:100px; height:400px; background-color:lightgreen; display: -webkit-flex; display: flex; -webkit-flex-direction: row; flex-direction: row; } .uprow{ width:100px; height:100%; background-color:pink; display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; -webkit-justify-content: space-around; justify-content: space-around; } .menu{ width:50px; height:50px; background-color:yellow; } .selected{ background-color:green; border:2px solid blue; } .downrow{ width:100%; height:100%; background-color:gray; display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; -webkit-justify-content: space-around; justify-content: space-around; } .pipe{ width:10%; height:5px; background-color:aqua; }
<div class="leftbox"> <div class="uprow"> <div class="menu one"></div> <div class="menu two"></div> <div class="menu three"></div> <div class="menu four"></div> <div class="menu five"></div> <div class="menu six"></div> </div> <div class="downrow"> <div class="pipe one"></div> <div class="pipe two"></div> <div class="pipe three"></div> <div class="pipe four"></div> <div class="pipe five"></div> <div class="pipe six"></div> </div> </div>
$('.uprow .menu').on('click', function() { $('.downrow .pipe').eq($(this).index()).css('width', '100%') })
.leftbox { width: 100px; height: 400px; background-color: lightgreen; display: -webkit-flex; display: flex; -webkit-flex-direction: row; flex-direction: row; } .uprow { width: 100px; height: 100%; background-color: pink; display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; -webkit-justify-content: space-around; justify-content: space-around; } .menu { width: 50px; height: 50px; background-color: yellow; } .selected { background-color: green; border: 2px solid blue; } .downrow { width: 100%; height: 100%; background-color: gray; display: -webkit-flex; display: flex; -webkit-flex-direction: column; flex-direction: column; -webkit-justify-content: space-around; justify-content: space-around; } .pipe { width: 10%; height: 5px; background-color: aqua; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script> <div class="leftbox"> <div class="uprow"> <div class="menu one"></div> <div class="menu two"></div> <div class="menu three"></div> <div class="menu four"></div> <div class="menu five"></div> <div class="menu six"></div> </div> <div class="downrow"> <div class="pipe one"></div> <div class="pipe two"></div> <div class="pipe three"></div> <div class="pipe four"></div> <div class="pipe five"></div> <div class="pipe six"></div> </div> </div>
Comments
Post a Comment