简体   繁体   中英

Injecting/returning a new element on screen

The code below shows that the div is injected into the a element. How do I display the div element so that it is not injected into anything. so instead of

<a href="#">
   <div class="example></div>
</a>

I have this

<a href="#">
</a>
<div class="example></div>

JS

display: function() {
        var n = new Element('a',{
            'class': 'postItem',
            'data-id': this.id,
            'text': this.title,
            'href': '#',
            events: {
                click: function(){
                    var id = this.get('data-id')
                    callThread(id);
                }
            }
        });

        var deleteT = new Element('div',{
            'class': 'deleteItem',
            'data-id': this.id,
            'text': 'Delete',

            events: {
                click: function(){
                    var deleteID = this.get('data-id')
                    deleteThread(deleteID)
                }
            }

        })

        deleteT.inject(n);
        return n;
    }

mootools inject method accept second parameter [where] : Element.inject

so what you asked is after :

deleteT.inject(n,'after');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM