javascript - how to access the child node from ul list? -
i have question jquery dom.
let have jsp code.
<c:foreach var="result" items="${resultlist }" varstatus="status"> <ul class="shlist" id="shlist"> <li class="fl"> <ul class="top"> <li>${ result.appsn}</li> <li>${result.mktype }</li> <li>${result.clastype }</li> <li>${result.appusegrade }</li> </ul> <div class="bottom"> <p class="fl">- ${result.appnm}</p> <span class="fr">${result.inputdt}</span> </div> <div class="sliding"> paragraph </div> </li> <li class="fr"><img src="${result.appleaderimg}" alt="" width="60" height="60" /></li> </ul> </c:foreach>
and want toggle sliding when click specific ul. , want access div class ="sliding"
here jquery.
$(document).ready(function(){ $("#shlist li").click(function(){ console.log("chlist clicked"); console.log($(this).children().eq(1)); console.log($(this).children().eq(2)); console.log($(this).next()); console.log($(this).next().next()); $(".sliding p").toggle(); }); });
im not sure how access paragraph sliding.
use $(this).find()
search selector inside li
clicked.
$(document).ready(function(){ $("#shlist li").click(function(){ console.log("chlist clicked"); console.log($(this).children().eq(1)); console.log($(this).children().eq(2)); console.log($(this).next()); console.log($(this).next().next()); $(this).find(".sliding p").toggle(); }); });
you should make original selector more specific: $("#shlist li.fl")
. otherwise used .fr
element , <li>
inside ul.top
.
Comments
Post a Comment