문제

I have the following HTML:

<div id="wrapper">
    <div onmouseover="displayDiv()">  <div id="thisIsTheDivToDisplay"></div   </div>
    <div onmouseover="displayDiv()">  <div id="thisIsTheDivToDisplay"></div>  </div>
    <div onmouseover="displayDiv()">  <div id="thisIsTheDivToDisplay"></div>  </div>
    <div onmouseover="displayDiv()">  <div id="thisIsTheDivToDisplay"></div>  </div>
</div>

I want to display the div inside, when I mouseover it's parent div. But I'cant use ID's, because the number of div's is random (depends on values in database). Is there any way in JavaScript to display that only child div (depending on div I mouseover)?

도움이 되었습니까?

해결책

why you need to use js? it can be solved via css. here is fiddle with working example

<div class="lol">
    <div>lol</div>
</div>

<div class="lol">
    <div>lol</div>
</div>

<div class="lol">
    <div>lol</div>
</div>


.lol{width:100px;height:100px; background:red;margin:10px}
.lol div{display:none}
.lol:hover div{display:block} 

http://jsfiddle.net/kpblc/4Vfra/

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top