简体   繁体   English

无法在没有页面刷新的情况下单击div中的span #id

[英]unable to click span #id in div without page refresh

I have the below HTML structure 我有以下HTML结构

<div style="position:relative; width:500px; top:50px; letter-spacing:3px; width:650px; margin:auto; font-size:16px;">
<span id ='Alist' style='cursor:pointer;'>A</span>
<span id ='Blist' style='cursor:pointer;'>B</span>
<span id='Clist' style='cursor:pointer;'>C</span>
<span id='Dlist' style='cursor:pointer;'>D</span>
<span id='Elist' style='cursor:pointer;'>E</span>
..
..
..
</div>

clicking on the respective alphabet would bring out a list of names. 单击相应的字母将显示一个名称列表。

Javascript code below 下面的Javascript代码

$(document).ready(function() {
$('#Alist').on('click', function() {$('#A').show();});
$('#Blist').on('click', function() {$('#B').show();});
$('#Clist').click(function() {$('#C').show();});
$('#Dlist').click(function() {$('#D').show();});
$('#Elist').click(function() {$('#E').show();});
});

I tried 我试过了

.on / .click as you can see on #Alist and #Blist

When I click "A" none of the other alphabets are clickable. 当我单击“ A”时,其他字母均不可单击。 If I have to refresh the page to click the next alphabet. 如果必须刷新页面以单击下一个字母。

What is wrong here? 怎么了 Pls let me know if you require anything is not clear. 请让我知道您是否需要任何不清楚的东西。

Elements #A, #B , etc. are floated or positioned. 元素#A, #B#A, #B等漂浮或定位。 Because of higher z-index they are above links and links aren't clickable. 由于较高的z-index因此它们位于链接上方,并且链接不可点击。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM