English 中文(简体)
利用 j或 Java
原标题:Play with Div using jQuery or Javascript

I want to move specific div to up on the up link. Same as to move div to down on the down link. As shown in screenshot, same as i want to insert div before specific div on the IB link. I want to insert div after specific div on the IA link. To delete specific div on the D link.

alt text http://freeimagehosting.in/images/204_screen_j.jpg screenshot

当然,现在还有许多替代办法可以达到上述特点,如缝.、正常 j等。

但我要知道,这将是实现这一目标的最佳途径。

任何反馈都会受到高度赞赏......!

<<>EDIT>:屏幕上链接现在!

问题回答

j 简言之,这无疑使这种事情更容易发生。

鉴于这一简单标记:

<div class="moveable" id="div1">
    One
    <a href= #  class="up">Move up</a>
    <a href= #  class="down">Move down</a><br/>
</div>
<div class="moveable" id="div2">
    Two
    <a href= #  class="up">Move up</a>
    <a href= #  class="down">Move down</a><br/>
</div>
<div class="moveable" id="div3">
    Three
    <a href= #  class="up">Move up</a>
    <a href= #  class="down">Move down</a><br/>
</div>

Qu

$( .moveable a.up ).live( click ,function(){
    var $div = $(this).parent( .moveable );
    var idx = $div.index();
    if(idx>0){          
        $div.remove();
        $( div.moveable:eq(  + (idx-1) + ) ).before($div);
    }
    return false;
});
$( .moveable a.down ).live( click ,function(){
    var $div = $(this).parent( .moveable );
    var idx = $div.index();
    if(idx<$( div.moveable ).length-1){         
        $div.remove();
        $( div.moveable:eq(  + idx + ) ).after($div);
    }
    return false;
});

这应当使你能够开始做一个插入。

http://jsfiddle.net/5hF98/“rel=”

请看Jquery-UI Sortable代码,但这不是你需要的,而是选择的。





相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签