[英]Javascript to show a hidden div
当满足条件时,我想显示一个隐藏的 div,如下所示。
<script>
jQuery.getJSON('http://freegeoip.net/json/', function(location) {
if (location.country_code == 'AU') {
jQuery.show(jQuery('#aus'));
}
});
</script>
<div id="aus" style="display:none;">
<div class="bottomBar">
This..
</div>
</div>
首先,您应该将其包装在document.ready
,其次您需要对.show使用以下语法:
jQuery(function() { // Wait for DOM to be ready
jQuery.getJSON('http://freegeoip.net/json/', function(location) {
if (location.country_code == 'AU') {
jQuery('#aus').show(); // Correct syntax for show method
}
});
});
尝试这个:
jQuery.getJSON('http://freegeoip.net/json/', function(location) {
if (location.country_code == 'AU') {
jQuery("#aus").show();
}
});
请通过这个: http : //api.jquery.com/show/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.