getElementsBySelector()
페이지 정보
작성자 서방님 댓글 0건 조회 106회 작성일 06-09-14 11:36본문
Inspired by Andy, I decided to have a crack at something I've been thinking about trying for a long time. document.getElementsBySelector
is a javascript function which takes a standard CSS style selector and returns an array of elements objects from the document that match that selector. For example:
document.getElementsBySelector('div#main p a.external')
This will return an array containing all of the links that have 'external' in their class attribute and are contained inside a paragraph which is itself contained inside a div with its id attribute set to 'main'.
So far I've only tested it on Phoenix but it seems to work as intended for the small number of test cases I've tried. If you spot any bugs please let me know. I'm about to fire up a Windows PC and see how much it breaks in IE...
Update: I've put together a demo page showing the function in action. It works fine in IE 6.
첨부파일
- getElementsBySelector.js (6.1K) 1회 다운로드 | DATE : 2008-09-08 11:39:04
- document_getElementsBySelector_Demo.mht (11.5K) 1회 다운로드 | DATE : 2008-09-08 11:39:04
댓글목록
등록된 댓글이 없습니다.