通过检查style="display:none"
内嵌样式,Javascript检查如何将<div>
添加到<li>
?
<li>
都有style="display:none"
。<li>
检查为style="display:none"
。<li>
的{{1}} style="display:none"
食物也会呈现为<div>
食物
<div style="display:none">
&#13;
答案 0 :(得分:2)
这样的东西?
var allHidden = true;
$("#food ul li").each(function(){
if($(this).is(":visible")){
allHidden = false;
}
});
if(allHidden){
$("#food").hide();
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div id="food"> Food <!-- Main Category -->
<ul>
<li style="display:none"> Pizza </li> <!-- Category Child Item -->
<li style="display:none"> Falafel </li> <!-- Category Child Item -->
<li style="display:none"> Donuts </li> <!-- Category Child Item -->
<li style="display:none"> Burger </li> <!-- Category Child Item -->
<li style="display:none"> Cheese Sandwich </li> <!-- Category Child Item -->
</ul>
</div>
答案 1 :(得分:0)
由于没有function instate(loc)
{
var a;
var geocoder = new google.maps.Geocoder;
var infowindow = new google.maps.InfoWindow
geocoder.geocode({'location': loc}, function(results, status) {
if (status === google.maps.GeocoderStatus.OK) {
if (results[1]) {
map.setZoom(5);
var arrAddress = results[0].address_components;
$.each(arrAddress, function (i, address_component) {
if (address_component.types[0] == "administrative_area_level_1"){
a = address_component.short_name;
}
//return false; // break the loop
});
} else {
window.alert('No results found');
}
} else {
window.alert('Geocoder failed due to: ' + status);
}
});
console.log(a);
}
标记,我在本机Javascript中为@bhargavponnapalli解决方案提供了不同的内容:
jquery
以下是fiddle。