jQuery.isFunction()
원문 링크
http://api.jquery.com/jQuery.isFunction/
개요 : 인자가 JavaScript 함수인지 판별합니다.
- jQuery.isFunction( obj )
- obj function인지 확인할 인자
Note: jQuery 1.3에서, 함수(functions) provided by the browser like alert() 같은 브라우저 내장 함수를 지원합니다.
그런데 alert 를 찍어보니 ie8에서는 false가 나오네요. 이 함수는 쓰지 않는 것이 좋겠습니다. 사실 쓸일도 없구요.
예 제
함수인지 확인하기
<!DOCTYPE html>
<html>
<head>
<style>
div { color:blue; margin:2px; font-size:14px; }
span { color:red; }
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
</head>
<body>
<div>jQuery.isFunction(objs[0]) = <span></span></div>
<div>jQuery.isFunction(objs[1]) = <span></span></div>
<div>jQuery.isFunction(objs[2]) = <span></span></div>
<div>jQuery.isFunction(objs[3]) = <span></span></div>
<div>jQuery.isFunction(objs[4]) = <span></span></div>
<script>
function stub() {
}
var objs = [
function () {},
{ x:15, y:20 },
null,
stub,
"function"
];
jQuery.each(objs, function (i) {
var isFunc = jQuery.isFunction(objs[i]);
$("span").eq(i).text(isFunc);
});
</script>
</body>
</html>미리보기
코맨트 생략;;;;
그럼 즐프하세요.
※ 본 예제는 http://www.jquery.com 에 있는 내용임을 밝힙니다.
'프로그래밍 > jQuery' 카테고리의 다른 글
| jQuery.isXMLDoc(), XML 문서인지 확인 (0) | 2012.07.02 |
|---|---|
| jQuery.isWindow(), Window 인지 확인 (0) | 2012.07.02 |
| jQuery.isPlainObject(), object인지 확인 (0) | 2012.07.02 |
| jQuery.isNumeric(), 숫자인지 확인 (2) | 2012.07.02 |
| jQuery.isEmptyObject(), 객체가 empty 인지 확인 (0) | 2012.07.02 |
| jQuery.isArray(), 배열인지 확인 (0) | 2012.07.02 |
| jQuery.inArray(), 배열 내의 값을 찾아서 인덱스를 반환 (0) | 2012.07.02 |
| jQuery.grep(), 배열 요소를 찾아 걸러내기 (0) | 2012.07.02 |