开发者

How get all selected values (not empty) for all selects in Prototype $$()?

开发者 https://www.devze.com 2023-03-17 14:58 出处:网络
How get all selected values (not empty) for all selects in document using Prototype dollar dollar fu开发者_C百科nction $$() ?

How get all selected values (not empty) for all selects in document using Prototype dollar dollar fu开发者_C百科nction $$() ?

Thanks, Celso


I don't know what your definition of "empty" is.

This needs to be known because most browsers will look at the value attribute as well as the text content of the option.

Assuming that there is a value attribute that has been set to an empty string, or there's no value and no text content, then you could do this:

var result = $$('select').invoke('getValue').without('');


One reason I switched to jQuery is that it is a lot easier to handle these situations.

You may need do it the hard way in Prototype:

$$('...').each(function(element) {
    if(element.innerHTML=='') {
        // your operation
    }

})
0

精彩评论

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