🤖 Merge PR #45618 update(jquery): even/odd from 3.5 by @peterblazejewicz

- `even` method
- `odd` method
- version bump
- tests amended

409cbda7fe
https://api.jquery.com/even/
https://api.jquery.com/odd/

Thanks!
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz) 2020-06-21 21:10:25 +02:00 committed by GitHub
parent f03e9ce90a
commit c5d5f696b2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 84 additions and 1 deletions

View File

@ -6167,6 +6167,81 @@ $( "p span" ).last().addClass( "highlight" );
```
*/
last(): this;
/**
* Reduce the set of matched elements to the even ones in the set, numbered from zero.
* @see \`{@link https://api.jquery.com/even/ }\`
* @since 3.5
* @example ````Highlight the even items in a list.
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>even demo</title>
<style>
.highlight {
background-color: yellow;
}
</style>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
<ul>
<li>Look:</li>
<li>This is some text in a list.</li>
<li>This is a note about it.</li>
<li>This is another note about it.</li>
</ul>
<script>
$( "ul li" ).even().addClass( "highlight" );
</script>
</body>
</html>
```
*/
even(): this;
/**
* Reduce the set of matched elements to the odd ones in the set, numbered from zero.
* @see \`{@link https://api.jquery.com/odd/ }\`
* @since 3.5
* @example ````Highlight the odd items in a list.
```html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>odd demo</title>
<style>
.highlight {
background-color: yellow;
}
</style>
<script src="https://code.jquery.com/jquery-3.5.0.js"></script>
</head>
<body>
<ul>
<li>Look:</li>
<li>This is some text in a list.</li>
<li>This is a note about it.</li>
<li>This is another note about it.</li>
</ul>
<script>
$( "ul li" ).odd().addClass( "highlight" );
</script>
</body>
</html>
```
*/
odd(): this;
/**
* Load data from the server and place the returned HTML into the matched element.
* @param url A string containing the URL to which the request is sent.

View File

@ -1,4 +1,4 @@
// Type definitions for jquery 3.3
// Type definitions for jquery 3.5
// Project: https://jquery.com
// Definitions by: Leonard Thieu <https://github.com/leonard-thieu>
// Boris Yankov <https://github.com/borisyankov>

View File

@ -5925,6 +5925,14 @@ function JQuery() {
$('p').find('span').first();
}
function even() {
$('li').even().css('background-color', 'red');
}
function odd() {
$('li').odd().css('background-color', 'red');
}
function offsetParent() {
// $ExpectType JQuery<HTMLElement>
$('p').offsetParent();