Trying to get this (simple!) jQuery exp开发者_C百科ression to work in Mootools
Jquery:
checkCurrentModule = function(){
jQuery(".module ul li.current").prepend("<b class='arrow'></b>");
};
And here is my attempt at it in Mootools
var checkCurrentModule = function(){
var injectModuleli = $$("li.current");
var currentArrow = new Element("<b class='arrow'></b>");
currentArrow.inject(injectModuleli);
};
To provide a solution as one-liner and with no dependency to mootools-more:
$$('li.current').grab(new Element('b.arrow'), 'top');
(I would just have added this as a comment, but i am not yet allowed to.)
var injectModuleli = document.getElement('li.current');
var currentArrow = Elements.from('<strong class="arrow"></strong>');
currentArrow.inject(injectModuleli, 'top');
Working example: http://jsfiddle.net/NGjgV/
I'm not really familiar with mootools, but I believe the following code does what you want:
var checkCurrentModule = function() {
new Element("b", {
"class": "arrow"
}).inject($$(".module ul li.current"), "top");
};
精彩评论