开发者

Searching for Nodes with Specific Text using the Prototype Javascript Framework

开发者 https://www.devze.com 2023-01-02 15:11 出处:网络
Does the Prototype Javascript library have a selector that\'s equivalent to jQuery\'s :contains()?If not, wh开发者_C百科at would what be \"The Prototype Way\" to selector/filter-down a list of element

Does the Prototype Javascript library have a selector that's equivalent to jQuery's :contains()? If not, wh开发者_C百科at would what be "The Prototype Way" to selector/filter-down a list of elements that contains a particular string.

For example, using the following

$$('#some_div dd a')

I may get back an array of 50 or so links. I only want the links that contain the work 'home'. In jQuery I'd do this

jQuery("#some_div dd a:contains('home')");

Is it possible to do something similar using Prototype? If not, is there an elegant way to filter out the array of 50 elements that gets returned.


The best (non-Sizzle) answer I've been able to find so is to filter things out with the findAll method.

$$(selector).findAll(function(e){ return e.innerHTML.indexOf(label) != -1;}) 


Have you read the article on the Sizzle intergreation.

http://prototypejs.org/2010/4/5/prototype-1-7-rc1-sizzle-layout-dimensions-api-event-delegation-and-more

This should help you.

0

精彩评论

暂无评论...
验证码 换一张
取 消