Сообщение от рони
|
циклом по атрибуту id
|
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(function() {
$("ul[id='products1']").each(function(indx, el){
$(el).has("li").length || $(el).html("This <i>unordered list (products1)</i> is <span class='green'>empty</span>");
});
});
</script>
</head>
<body>
<ul id="products1">
</ul>
<ul id="products1">
<li>test</li>
</ul>
<ul id="products1">
</ul>
</body>
</html>