jquery - Display text of just the element clicked -


i need able click on div, show text within it, when clicking on div, hide other text in other divs , show text in clicked div.

code here

http://jsfiddle.net/refxq/140/

<div class="myclass"><span>first</span></div> <div class="myclass"><span>second</span></div> <div class="myclass"><span>third</span></div>  .myclass{     height:50px;     width:100%;     background-color:red;     margin:2px; } .myclass span{   display:none; }  $(".myclass").click(function() {   // hide item spans   $(".myclass span").hide();   // show element next   $(this).first().show(); }); 

this work : see fiddle

$(".myclass").click(function() {   // hide item spans   $(".myclass span").hide();   // show element next   $(this).find('span').show(); }); 

Comments

Popular posts from this blog

javascript - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -