I have this function in Jquery which basically says when you click on the ID "MyID" do a fadetoggle of all the li tags where the class is not equal to "nav":
开发者_JS百科$("#MyID").click(function () {
$('li[class!="nav"]').fadeToggle("fast", "linear");
});
Is there a way to do this in Prototype js? Specifically is there a way to use a selector that selects a class != (not equal to) something?
Try this,
$("MyID").click(function () {
$$('li :not(.nav)').fadeToggle("fast", "linear");
});
Hope this helps...
From the Prototype documentation:
Supported CSS syntax
...
- Attribute selectors: the full CSS 2.1 set of
[attr],[attr=value],[attr~=value]and[attr|=value]. It also supports[attr!=value]. If the value you're matching against includes a space, be sure to enclose the value in quotation marks ([title="Hello World!"]).
So the 'not equal to' comparator still works, you only need to remember to use the $$ function.
However as tylermwashburn points out it can be different with class names.
Event.observe('MyID', 'click', function() {
Effect.multiple($$('li:not(.nav)'), function(element){
Effect.toggle(element, 'appear');
});
});
The selector :not(.nav) is the same as :not(class~=nav) as explained here
加载中,请稍侯......
精彩评论