Is that clear?
views:
267answers:
4
A:
...and if you need them all:
var lowerBoundary = 0;
var upperBoundary = 4;
var wrappedSet = $("#target > *")
.filter
(
function(i)
{
return i >= lowerBoundary && i <= upperBoundary;
}
);
alert(wrappedSet.size());
This sets wrappedSet to contain the first five elements of target as a group.
David Andres
2009-09-19 15:04:09
A:
Try this:
$('#testdiv > :lt(5)');
It will return all the elements in a result set less than n (zero based)
<html xmlns="http://www.w3.org/1999/xhtml">
<head >
<title></title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
</head>
<body>
<div id="testdiv">
<input id="Text1" type="text" />
<input id="Text2" type="text" />
<input id="Text3" type="text" />
<input id="Text4" type="text" />
<input id="Text5" type="text" />
<input id="Text6" type="text" />
<input id="Text7" type="text" />
</div>
</body>
<script type="text/javascript">
var items = $('#testdiv > :lt(5)');
</script>
</html>
So the above code will return first five elements in this case first five textboxes.
Raghav Khunger
2009-09-19 16:03:25