使用jquery将元素li移动到ul中

时间:2010-05-18 07:06:38

标签: jquery css

我正在寻找一种解决方案来移动我需要移动的元素

  • ....即时通讯使用jquery,我离开这里的代码我尝试了不同的东西,但没有工作。

    这是大菜单

     <ul class="sf-menu">
    
        <li><a href="">Student Centre</a>
        <ul>
            <li><a href="9">STUDENT CENTRAL WEBSITE</a></li>
            <li><a href="10">STUDENT CENTRAL EMAIL</a></li>
            <li><a href="11">CCM STUDENT SURVIAL TIPS</a></li>
            <li><a href="12">VET TUTTTION ASSURANSE</a></li>
            <li><a href="13">WHAT GOING ON AT CCM</a></li>
            <li><a href="14">IMPORTANT STUDENTS NOTICE</a></li>
        </ul>
        </li>
    
        <li><a href="">Research</a>
        <ul>
            <li><a href="_16">WHAT IS HOLISTIC KINESIOLOGY ?</a></li>
            <li><a href="_17">TRANF. CHILDREN W/ LEARNING DIFFICULTIES</a></li>
            <li><a href="_18">HEALING WITH HOLISTIC KINESIOLOGY</a></li>
            <li><a href="_19">UNDERSTANDING ASPERGER'S SYNDROME</a></li>
            <li><a href="_20">DAVID CORBY THE DIRECTOR OF CCM</a></li>
            <li><a href="_21">HELPING PEOPLE CREATE THEIR OWN MIRACLES</a></li>
            <li><a href="_22">MAGNESIUM AND COLLOIDAL MINERALS</a></li>
            <li><a href="_23">BRAIN ENERGETICS CHAKRAS AND NADIS</a></li>
            <li><a href="_24">KINESIOLOGY FAQ'S</a></li>'
         </ul>
        </li>
        <li><a href="25">Contact Us</a></li>
        <li><a href="26">A - Z</a></li>
    
     </ul> 
    

    我需要将此li添加到ul但我需要在第一个

  • 之后放入第二位

    <li id="faculty">
        <a href="#">Faculty Courses </a> 
            <ul>
                <li><a href="">INTENSE SHORT COURSES</a><ul>
                <li><a href="_59">CRYSTAL KINESIOLOGY ONE</a></li>
                <li><a href="_60">APPLIED PHYSIOLOGY</a></li>
                <li><a href="_61">VIBRATIONAL HEALING SYSTEMS 1</a></li>
                <li><a href="_62">VIBRATIONAL HEALING SYSTEMS 2</a></li>
                <li><a href="_63">VIBRATIONAL HEALING SYSTEMS 3</a></li>
                <li><a href="_64">VIBRATIONAL HEALING SYSTEMS 6</a></li>
                <li><a href="_65">NUTRITIONAL KINESIOLOGY</a></li>
                <li><a href="_66">QUANTUM HARMONICS</a></li><li><a href="_67">CHAKRA HOLOGRAM</a></li>
                <li><a href="_68">CLINICAL APPLICATIONS OF KINESIOLOGY</a></li>
                <li><a href="_69">COUNSELLING KINESIOLOGY</a></li>
                <li><a href="_70">HARMONISING CHI FLOW</a></li>
             </ul>
             </li>
             <li><a href="=53">FREE INTRUCTION COURSE DAYS</a>
                <ul>
                    <li><a href="=53_56">HOLISTIC KINESIOLOGY</a></li>
                    <li><a href="=53_57">TRANSPERSONAL COUNSELLING</a></li>
                    <li><a href="=53_58">SHAMMANISM &amp; TRANSFORMATIONAL MASK</a></li>
                </ul>
    
                </li>
    
    
                <li><a href="=50">DIPLOMA MASK AND TRADITIONAL HEALING</a></li>
                <li><a href="=43">DIPLOMA TRANSPERSONAL ART THERAPY</a></li>
                <li><a href="=42">DIPLOMA HOLISTIC KINESIOLOGY</a></li>
                <li><a href="=47">ADVANCE DIPLOMA HOLISTIC KINESIOLOGY</a></li>
                <li><a href="=48">DIPLOMA DINAMIC AND FUNCTIONAL</a></li>
                <li><a href="=49">CERTIFICATE MASK AND TRADITIONAL HEALING</a></li>
                <li><a href="=51">DIPLOMA TRANSPERSONAL COUNSELLING</a></li>
                <li><a href="=52">STUDENT CLINICS</a></li>
            </ul>
    
     </li>
    

    我需要你的帮助

    提前致谢

  • 1 个答案:

    答案 0 :(得分:1)

    如果您希望获得如下结构:

    <ul class="sf-menu">
        <li>Student Center ...</li>
        <li>Faculty Courses ...</li> <!-- Inserted here -->
        <li>Research ...</li>
        <li>Contact Us</li>
        <li>A - Z</li>
    </ul>
    

    然后,您可以使用:

    $("#faculty").insertAfter(".sf-menu > li:first");​
    

    它在#faculty内的第一个<li>节点之后插入#sf-menu列表项。

    了解http://api.jquery.com/category/manipulation/

    上的所有DOM操作函数