2016-09-16 66 views
0

根据所选选项,隐藏并显示div。长话短说。隐藏并显示jquery - 不工作但用小提琴工作正常

  • 1级和2 - 隐藏的div名为 “custompanel”
  • 定制 - 显示DIV命名为 “custompanel”

正常工作与 JSFIDDLE 但我想这个问题将与CDN的。无法弄清楚。需要帮忙。

HTML 
<head> 
<meta charset="utf-8"> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
<title>Password Generator</title> 
<!-- Latest compiled and minified CSS --> 

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous"> 
<!-- Optional theme --> 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous"> 
<!-- Latest compiled and minified JavaScript --> 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script> 
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 

<link rel="stylesheet" type="text/css" href="screen.css" media="screen, projection" /> 
<script> 
$(document).ready(function() { 
    $('#generator-mixcase').on('change',function(){ 
     if($(this).val() == 'custom') { 
      $('.custompanel').show(); 
     } else { 
      $('.custompanel').hide(); 
     } 
    }); 
}); 
</script> 
</head> 

问题:当我选择自定义时,它不显示div。请找到下面的图片。 browser page

Inspect element showed this exception

异常显示了在jquery的CDN错误。我的jQuery的CDN错了吗?

"Error: Failed to execute 'querySelectorAll' on 'Element': '*,:x' is not a valid selector.↵  
at Error (native)↵ at https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:2:10694↵  
at ia (https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:2:7550)↵ 
at fa.setDocument (https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:2:10432)↵  
at https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:2:22250↵  
at https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:2:22970↵  
at https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:2:207↵  
at https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js:2:212" 
+0

刚刚在本地进行了测试,至今没有问题:http://pastebin.com/Wv029pEV尝试检查控制台是否有错误。 – yuriy636

+0

在它的破碎版本中,显示 - 或隐藏面板不工作? – Sam0

+0

运行代码时是否存在这些元素?或者他们被插入后?控制台中的任何错误?没有太多的工作在这里 – charlietfl

回答

0

前段时间我有这个错误,请尝试删除bootstrap includes。

+0

如果他真的想要使用Bootstrap呢? – Barmar

+0

是的!我需要引导。它的客户端请求有移动友好屏幕 –

+0

删除引导没有工作 –

0

试试这个:的

jQuery(document).ready(function($) 

代替

$(document).ready(function() 

它的工作原理,验证!

你必须加载jQuery之前加载其依赖组件。