getElementsBySelector() > html

본문 바로가기
사이트 내 전체검색

html

getElementsBySelector()

페이지 정보

작성자 서방님 댓글 0건 조회 297회 작성일 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.

http://simon.incutio.com/js/getElementsBySelector.html

첨부파일

댓글목록

등록된 댓글이 없습니다.

Total 323건 1 페이지
게시물 검색

회원로그인

접속자집계

오늘
295
어제
1,871
최대
2,993
전체
261,031
Latest Crypto Fear & Greed Index

그누보드5
Copyright © 서방님.kr All rights reserved.