English 中文(简体)
jquery to change html order of sibling div elements?
原标题:jquery to change html order of sibling div elements?
  • 时间:2012-01-15 22:01:23
  •  标签:
  • jquery

我的赞扬是:

<ul class="menu collapsible">
    <li class= expand sectionTitle home >
        <a class= clicker  href= # >Home</a>
        <ul class= acitem >
            <li class="section">stuff goes here
        </ul>
    </li>

    <li class= expand sectionTitle section1 >
        <a class= clicker  href= # >Section 1</a>
        <ul class= acitem >
            <li class="section">stuff goes here
        </ul>
    </li>

    <li class= expand sectionTitle section2 >
        <a class= clicker  href= # >Section 2</a>
        <ul class= acitem >
            <li class="section">stuff goes here
        </ul>
    </li>
</ul>

我愿补充处理礼仪行为的j Query 稿(见下文),以便在点击“立克”元素时,其母体滑坡到第二位。 我总是希望“Home”四分五裂,但我希望在第二位职位上扩大任何四分之四。

Here is the jQuery that controls the menu s accordian behavior:

jQuery.fn.initMenu = function() {  
    return this.each(function(){
        var theMenu = $(this).get(0);
        $( .acitem , this).hide();
        $( li.expand > .acitem , this).show();
        $( li.expand > .acitem , this).prev().addClass( active );
        $( li a , this).click(
            function() {
                var theElement = $(this).next();
                var parent = this.parentNode.parentNode;
                if($(parent).hasClass( noaccordion )) {
                    $(theElement).slideToggle( normal , function() {
                        if ($(this).is( :visible )) {
                            $(this).prev().addClass( active );
                        }
                        else {
                            $(this).prev().removeClass( active );
                        }    
                    });
                    return false;
                }
                else {
                    if(theElement.hasClass( acitem ) && theElement.is( :visible )) {
                        if($(parent).hasClass( collapsible )) {
                            $( .acitem:visible , parent).first().slideUp( normal , 
                            function() {
                                $( .acitem:visible , parent).first().prev().removeClass( active );
                            }
                        );
                    }
                    return false;
                }
                if(theElement.hasClass( acitem ) && !theElement.is( :visible )) {                        
                    $( .acitem:visible , parent).first().slideUp( normal , function() {
                        $(this).prev().removeClass( active );
                    });
                    theElement.slideDown( normal , function() {
                        $(this).prev().addClass( active );
                    });
                    return false;
                }
            }
        }
    );
});
};

$(document).ready(function() {$( .menu ).initMenu();});
最佳回答

Like this?

http://jsfiddle.net/hPZs2/

增 编

var homeCheckTmp;

您在上表和之后发表的可变声明

homeCheckTmp = theElement.closest( li.expand );
if(!homeCheckTmp.is("li.home")) {
    homeCheckTmp.insertAfter(homeCheckTmp.siblings( .home ));
}

在将要素缩小之前。

问题回答

暂无回答




相关问题
getGridParam is not a function

The HTML: <a href="javascript:void(0)" id="m1">Get Selected id s</a> The Function: jQuery("#m1").click( function() { var s; s = jQuery("#list4").getGridParam( selarrrow )...

selected text in iframe

How to get a selected text inside a iframe. I my page i m having a iframe which is editable true. So how can i get the selected text in that iframe.

jQuery cycle page with links

I am using the cycle plugin with pager functionality like this : $j( #homebox ) .cycle({ fx: fade , speed: fast , timeout: 9000, pager: #home-thumbs , ...

jquery ui dialog opens only once

I have a button that opens a dialog when clicked. The dialog displays a div that was hidden After I close the dialog by clicking the X icon, the dialog can t be opened again.

jConfirm with this existing code

I need help to use jConfirm with this existing code (php & Jquery & jAlert). function logout() { if (confirm("Do you really want to logout?")) window.location.href = "logout.php"; } ...

Wrap text after particular symbol with jQuery

What I m trying to do, is wrap text into div inside ll tag. It wouldn t be a problem, but I need to wrap text that appears particularly after "-" (minus) including "minus" itself. This is my html: &...

热门标签