javascript - How to Add HTML into an existing div with MooTools - Stack Overflow

Good Day Folks.Pardon my experience with MooTools.To sum up, the CMS generates this code:<div class=

Good Day Folks.

Pardon my experience with MooTools.

To sum up, the CMS generates this code:

<div class="gk_tab gk_tab-style1 clearfix-tabs" id="slideshow-tabs" style="width: 418px; ">
    <ul class="gk_tab_ul-style1">
        <li id="slideshow-tabs_tab_1" class="active"><span>Video</span></li>
        <li id="slideshow-tabs_tab_2" class=""><span>Calendar</span></li>
    </ul>
</div>

I need to able to insert this code when the page finishes loading:

<li id="slideshow-tabs_tab_0" class=""><a><span>Video</span></a></li>

In a particular space. The end result should be:

<div class="gk_tab gk_tab-style1 clearfix-tabs" id="slideshow-tabs" style="width: 418px; ">
    <ul class="gk_tab_ul-style1">
        <li id="slideshow-tabs_tab_0" class=""><a><span>Video</span></a></li>
        <li id="slideshow-tabs_tab_1" class="active"><span>Video</span></li>
        <li id="slideshow-tabs_tab_2" class=""><span>Calendar</span></li>
    </ul>
</div>

So I know I would need to create a new element with the new HTML I want to add and then interject it, but unsure how as efficiently as possible. Oh and yes, I have a specific reasoning for needing to do this, but didn't want to boggle down this post with all the extra info and code. Thanks so much in advance! I'll keep searching on here in the mean time to see if I can figure it out.

PS. The class I'm interjecting it into exists in other parts of the page. So I would have to make sure to specify the id="slideshow-tabs" as well.

Good Day Folks.

Pardon my experience with MooTools.

To sum up, the CMS generates this code:

<div class="gk_tab gk_tab-style1 clearfix-tabs" id="slideshow-tabs" style="width: 418px; ">
    <ul class="gk_tab_ul-style1">
        <li id="slideshow-tabs_tab_1" class="active"><span>Video</span></li>
        <li id="slideshow-tabs_tab_2" class=""><span>Calendar</span></li>
    </ul>
</div>

I need to able to insert this code when the page finishes loading:

<li id="slideshow-tabs_tab_0" class=""><a><span>Video</span></a></li>

In a particular space. The end result should be:

<div class="gk_tab gk_tab-style1 clearfix-tabs" id="slideshow-tabs" style="width: 418px; ">
    <ul class="gk_tab_ul-style1">
        <li id="slideshow-tabs_tab_0" class=""><a><span>Video</span></a></li>
        <li id="slideshow-tabs_tab_1" class="active"><span>Video</span></li>
        <li id="slideshow-tabs_tab_2" class=""><span>Calendar</span></li>
    </ul>
</div>

So I know I would need to create a new element with the new HTML I want to add and then interject it, but unsure how as efficiently as possible. Oh and yes, I have a specific reasoning for needing to do this, but didn't want to boggle down this post with all the extra info and code. Thanks so much in advance! I'll keep searching on here in the mean time to see if I can figure it out.

PS. The class I'm interjecting it into exists in other parts of the page. So I would have to make sure to specify the id="slideshow-tabs" as well.

Share Improve this question edited Mar 8, 2011 at 22:23 TechRemarker asked Mar 8, 2011 at 22:15 TechRemarkerTechRemarker 2,93811 gold badges42 silver badges60 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 6

Using MooTools 1.3:

var li = new Element('li#slideshow-tabs_tab_0'), a = new Element('a'), span = new Element('span', {'text': 'Video'});
span.inject(a);
a.inject(li);
li.inject($$('#slideshow-tabs ul')[0], 'top');

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744791675a4593952.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信