javascript - How to do first-of-type -


here fiddle

here html

<div class='cl' data-gen='1'>one</div> <div class='cl'  data-gen='5'>two</div> <div class='cl'  data-gen='6'>three</div> <br> <div class='jl jl_1' style='display:none'>alpha</div> <div class='jl jl_1' style='display:none'>andrew</div> <div class='jl jl_1' style='display:none'>christ</div> <div class='jl jl_5' style='display:none'>anto</div> <div class='jl jl_5' style='display:none'>brito</div> <div class='jl jl_6' style='display:none'>oyster</div> <div class='jl jl_6' style='display:none'>beta</div> 

here js

$(document).on('click','.cl',function(){    $('.jl').hide().filter('.jl_' + $(this).data('gen') ).show(); }) 

i want display first jl_1 default. how can ?

help pls

just trigger click on first one.

$('.cl').first().click(); 

demo


Comments

Popular posts from this blog

authentication - Mongodb revoke acccess to connect test database -

r - Update two sets of radiobuttons reactively - shiny -

ios - Realm over CoreData should I use NSFetchedResultController or a Dictionary? -