javascript - jQuery on click toggle siblings -
i trying toggle arrows when click link, on click action working cannot make siblings toggle.
have idea missing.
thanks
html code :
<div class="box"> <span class="info-box-title" > <i class="fa fa-thumbs-up"></i> <a class="toggle" href="#yeswebsite"> <b>website</b>: <?php echo $parsedjson1->website; ?> </a> </span> <div class="arrow-up">▲</div> <div class="arrow-down">▼</div> <div id="yeswebsite" class="hidden"> <p>informatiile privind pagina ta cuprind si adresa de website. aceasta trimite vizitatorii direct pe siteul tau pentru afla mai multe informatii. </p> </div> </div>
jquery code is
$("span>a.toggle").click(function () { console.log('it works'); $(this).siblings(".arrow-up, .arrow-down").toggle(); });
$(this).siblings(".arrow-up, .arrow-down")
finds siblings of <a>
, required elements siblings of <span>
.
<span class="info-box-title"> <i class="fa fa-thumbs-up"></i> -------- $(this).siblings() <-+ <a class="toggle"></a> --------- $(this)--------------' </span> <div class="arrow-up">▲</div> ---- required <div class="arrow-down">▼</div> ---- required
use .closest()
find parent,
$(this).closest('span').siblings(".arrow-up, .arrow-down").toggle();
Comments
Post a Comment