开发者

Prototype Selector Problem IE 8

I have a validation class that uses the following CSS selector (Prototype 1.6.1):

$$('*[class*=validate]')

The idea is I have various class names for elements that start with 'validate', ie 'validate-numeric' or 'validate-url'. So, I'd like to grab any element with the word validate in the class attribute.

It works in just about any other browser, including IE 6 & 7. In IE 8, it doesn't seem to select the proper elements. I tried to do some debugging in IE's developer tools, but the console, in all it's wisdom, only outputs {...} fo开发者_JAVA技巧r arrays and objects. Is there something I am missing? Yes, it's a CSS3 selector, but I thought it was still implemented in Prototype and 6 & 7 both worked with it.


If you still haven't figured out, here's an alternative. Classify all your elements as such:

<div class="validate numeric">foo</div>
<div class="validate url">bar</div>
<div class="validate email">world</div>

Then this surely will work in IE8:

$$('.validate');

I'm guessing you're writing some code for form validation and these are errors that could occur. The CSS for my schema would be

.validate { color: red }
.numeric { margin: 1px }
.url { margin: 2px; }
.email { padding: 3px; }

Whereas your CSS schema wouldn't be modular - thus making it hard to maintain as your add more and more error types.

.validate_numeric,
.validate_url,
.validate_email {
 color: red;
}

.validate_numeric { margin: 1px }
.validate_url { margin: 2px; }
.validate_email { padding: 3px; }
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜