Javascript jQuery click()在chrome和mobile中不起作用
我正在使用Jquery隐藏一个div,并在Javascript jQuery click()在chrome和mobile中不起作用,javascript,jquery,html,css,twitter-bootstrap,Javascript,Jquery,Html,Css,Twitter Bootstrap,我正在使用Jquery隐藏一个div,并在 我的脚本链接在正文的末尾,并按以下方式排序: <script type = "text/javascript" src = "js/jquery-1.9.1.js"></script> <script type = "text/javascript" src = "js/ajax_jquery.min.js"></script> <script type = "text/javasc
-
-
我的脚本链接在正文的末尾,并按以下方式排序:
<script type = "text/javascript" src = "js/jquery-1.9.1.js"></script>
<script type = "text/javascript" src = "js/ajax_jquery.min.js"></script>
<script type = "text/javascript" src = "js/bootstrap.min.js"></script>
<script type = "text/javascript" src = "js/jquery-ui.js"></script>
<script type = "text/javascript" src = "js/main.js"></script>
我使用
javascript:void(0)
来避免冲突,并将代码更改为纯jQuery
$(文档).ready(函数(){
$(“#acc”)。单击(功能(g){
$('a').css('display','none');
$('#b').css('display','none');
$('c').css('display','block');
});
});代码>
-
-
A.
B
C
当您要将事件附加到动态html元素时,
你应该使用
替换:
$("#acc").click(function(g) {
document.getElementById("a").style.display = "none";
document.getElementById("b").style.display = "none";
document.getElementById("c").style.display = "block";
});
$('body').on('click', 'a#acc', function() {
document.getElementById("a").style.display = "none";
document.getElementById("b").style.display = "none";
document.getElementById("c").style.display = "block";
});
与:
$("#acc").click(function(g) {
document.getElementById("a").style.display = "none";
document.getElementById("b").style.display = "none";
document.getElementById("c").style.display = "block";
});
$('body').on('click', 'a#acc', function() {
document.getElementById("a").style.display = "none";
document.getElementById("b").style.display = "none";
document.getElementById("c").style.display = "block";
});
fiddle会有帮助的请创建没有id作为acc\u设置
@Rayon:非常抱歉这是acc不是acc\u设置Rayon Dabre的点有效吗?acc_设置在哪里?我试过了,它在chrome、opera和手机上仍然不起作用。也许你在其他部分有问题,不是在code
,是的,它在代码段中起作用,但在我的页面中不起作用。我的Js在FF和IE中工作,但在Chromecan中不工作。我们可以获得链接以便查看它吗?我看到您使用
尝试使用