forked from SyncfusionSuccinctlyE-Books/jQuery-Succinctly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample026.html
21 lines (21 loc) · 882 Bytes
/
sample026.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
<!DOCTYPE html>
<html lang="en">
<body>
<div style="position: absolute">absolute</div>
<span style="position: absolute">absolute</span>
<div>static</div>
<div style="position: absolute">absolute</div>
<div>static</div>
<span style="position: absolute">absolute</span>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script> (function ($) {
// Define custom filter by extending $.expr[':']
$.expr[':'].positionAbsolute = function (element)
{ return $(element).css('position') === 'absolute'; };
// How many elements in the page are absolutely positioned?
alert($(':positionAbsolute').length); // Alerts "4"
// How many div elements are absolutely positioned?
alert($('div:positionAbsolute').length); // Alerts "2"
})(jQuery); </script>
</body>
</html>