Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
feabeb85
Commit
feabeb85
authored
Oct 02, 2006
by
Jörn Zaefferer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added ifelse method, fixed bug #160 for IE6
parent
64425675
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
0 deletions
+49
-0
jquery.js
src/jquery/jquery.js
+49
-0
No files found.
src/jquery/jquery.js
View file @
feabeb85
...
@@ -1047,6 +1047,7 @@ jQuery.fn = jQuery.prototype = {
...
@@ -1047,6 +1047,7 @@ jQuery.fn = jQuery.prototype = {
* @example $("p").not("#selected")
* @example $("p").not("#selected")
* @before <p>Hello</p><p id="selected">Hello Again</p>
* @before <p>Hello</p><p id="selected">Hello Again</p>
* @result [ <p>Hello</p> ]
* @result [ <p>Hello</p> ]
*
* @test ok($("#main > p#ap > a").not("#google").length == 2, ".not")
* @test ok($("#main > p#ap > a").not("#google").length == 2, ".not")
*
*
* @name not
* @name not
...
@@ -1157,6 +1158,52 @@ jQuery.fn = jQuery.prototype = {
...
@@ -1157,6 +1158,52 @@ jQuery.fn = jQuery.prototype = {
is
:
function
(
expr
)
{
is
:
function
(
expr
)
{
return
expr
?
jQuery
.
filter
(
expr
,
this
).
r
.
length
>
0
:
false
;
return
expr
?
jQuery
.
filter
(
expr
,
this
).
r
.
length
>
0
:
false
;
},
},
/**
* Executes the first callback for every element that fits the expression
* and executes the second callback for every element that does not fit
* the expression.
*
* @example $('div').ifelse(':visible',
* function() { $(this).slideUp(); },
function() { $(this).slideDown(); }
* );
* @desc Slides down all visible div elements and slides down all others
*
* @test var checked = 0, notChecked = 0;
* var inputChecked = $(':input').ifelse(':checked',
* function() { checked++; },
* function() { notChecked++ }
* );
* ok( checked == 2, 'Check is if/else: Count checked elements' );
* ok( notChecked == 12, 'Check is if/else: Count unchecked elements' );
*
* $('#first, #foo, #ap').ifelse('p',
* function() { $(this).html('me == p') },
* function() { $(this).html('me != p') }
* );
* ok( $('#first').text() == 'me == p', 'Check filter-if-clause' );
* ok( $('#foo').text() == 'me != p', 'Check else-clause' );
* ok( $('#ap').text() == 'me == p', 'Check filter-if-clause' );
*
* @name ifelse
* @type jQuery
* @param String expression The expression with which to filter
* @param Function ifCallback Called for elements that fit the expression
* @param Function elseCallback Called for elements that don't fit the expression
* @cat DOM/Traversing
*/
ifelse
:
function
(
expr
,
ifCallback
,
elseCallback
)
{
var
ifCallback
=
ifCallback
||
function
()
{};
var
elseCalllback
=
elseCallback
||
function
()
{};
return
this
.
each
(
function
()
{
if
(
$
(
this
).
is
(
expr
))
{
ifCallback
.
apply
(
this
);
}
else
{
elseCallback
.
apply
(
this
);
}
});
},
/**
/**
*
*
...
@@ -1824,6 +1871,8 @@ jQuery.extend({
...
@@ -1824,6 +1871,8 @@ jQuery.extend({
if
(
fix
[
name
]
)
{
if
(
fix
[
name
]
)
{
if
(
value
!=
undefined
)
elem
[
fix
[
name
]]
=
value
;
if
(
value
!=
undefined
)
elem
[
fix
[
name
]]
=
value
;
return
elem
[
fix
[
name
]];
return
elem
[
fix
[
name
]];
}
else
if
(
value
==
undefined
&&
$
.
browser
.
msie
&&
elem
.
nodeName
&&
elem
.
nodeName
.
toUpperCase
()
==
'FORM'
&&
(
name
==
'action'
||
name
==
'method'
)
)
{
return
elem
.
getAttributeNode
(
name
).
nodeValue
;
}
else
if
(
elem
.
getAttribute
!=
undefined
)
{
}
else
if
(
elem
.
getAttribute
!=
undefined
)
{
if
(
value
!=
undefined
)
elem
.
setAttribute
(
name
,
value
);
if
(
value
!=
undefined
)
elem
.
setAttribute
(
name
,
value
);
return
elem
.
getAttribute
(
name
,
2
);
return
elem
.
getAttribute
(
name
,
2
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment