开发者

Jquery to Mootools

开发者 https://www.devze.com 2023-04-13 05:19 出处:网络
Trying to get this (simple!) jQuery exp开发者_C百科ression to work in Mootools Jquery: checkCurrentModule = function(){

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");
};
0

精彩评论

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