TKS
-
Total Posts
:
188
- Scores: 0
-
Reward points
:
0
- Joined: 5/16/2008
-
Status: offline
|
Javascript - Is there a shorter way of writing... ?
Tuesday, July 22, 2008 4:17 AM
( permalink)
window.event.srcElement.id=="idp" || window.event.srcElement.id=="idq" || window.event.srcElement.id=="idr" || window.event.srcElement.id=="ids" Got any ideas?
|
|
|
|
mcnd
-
Total Posts
:
50
- Scores: 2
-
Reward points
:
0
- Joined: 4/27/2008
-
Status: offline
|
RE: Javascript - Is there a shorter way of writing... ?
Sunday, July 27, 2008 10:42 PM
( permalink)
Try this
('/idp/idq/idr/ids/').indexOf('/'+window.event.srcElement.id+'/') > -1
half the size, but i have not tried the speed
|
|
|
|
TNO
-
Total Posts
:
2094
- Scores: 36
-
Reward points
:
0
- Joined: 12/18/2004
- Location: Earth
-
Status: offline
|
RE: Javascript - Is there a shorter way of writing... ?
Saturday, August 02, 2008 4:25 AM
( permalink)
window.event.srcElement.id === ("idp" ||"idq" || "idr" ||"ids")
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
|
|
TNO
-
Total Posts
:
2094
- Scores: 36
-
Reward points
:
0
- Joined: 12/18/2004
- Location: Earth
-
Status: offline
|
RE: Javascript - Is there a shorter way of writing... ?
Saturday, August 02, 2008 4:30 AM
( permalink)
Here's another trick for you that may be useful: document.getElementById(("something" || "somethingElse")).tagName shortcut operators are nice
To iterate is human, to recurse divine. -- L. Peter Deutsch
|
|
|
|
TKS
-
Total Posts
:
188
- Scores: 0
-
Reward points
:
0
- Joined: 5/16/2008
-
Status: offline
|
RE: Javascript - Is there a shorter way of writing... ?
Thursday, August 21, 2008 5:17 AM
( permalink)
Makes the code so much faster. Thanks guys! 
|
|
|
|