3

I am trying to match in Mootools [version 1.11] a multiple CSS attribute as in this element:

<input type="radio" value="dev" name="radio_server">

I would like to match this element that has both type='radio' and value='dev' attribs. Tried this but this is not working

$$('input[type=radio][value=dev]')

also not working

$$('input[type=radio,value=dev]')
$$('input[type=radio && value=dev]')

this page: http://api.jquery.com/multiple-attribute-selector/ has a JQuery solution is there anything like also for Mootools ?

6
  • 3
    which version of mootools??? works fine in 1.3.2 - jsfiddle.net/jTaYA - and in 1.2.5 jsfiddle.net/jTaYA/1 Commented Jun 7, 2011 at 9:38
  • 2
    Works fine: jsfiddle.net/BPZch Commented Jun 7, 2011 at 9:39
  • 1
    Your first selector is correct. The other two are not. Commented Jun 7, 2011 at 9:41
  • As has already been shown, there's nothing wrong with the (first attempt) code you've given. Try making a jsFiddle/JS Bin test case showing how it's not working for you. Commented Jun 7, 2011 at 9:53
  • 4
    in 1.11 you can use collection.filter(function(el) { return el.getProperty("type") == 'radio' && el.getValue() == 'dev' }); Commented Jun 7, 2011 at 12:03

1 Answer 1

1

as mentioned by Dimitar, in mootools 1.11, you could chain a filter function to filter your array, here is an example : http://jsfiddle.net/HHQNE/

here is what's in there :

function radioAndDevPredicate(elt) {
     return elt.getProperty("type") == "radio" && elt.getProperty("value") == "dev";
}

document
    .getElements("input")
    .filter(radioAndDevPredicate)
    .each(function (foo) {
        foo.addClass("active");
    });
Sign up to request clarification or add additional context in comments.

1 Comment

thx. fixed long time ago just by replacing with a newer version of mootools.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.