javascript - Jquery Sortable. Adjusting CSS on Selected / Drag -



javascript - Jquery Sortable. Adjusting CSS on Selected / Drag -

using jquery sortable. want simple css switch function can alter background colour of field have selected (<div class='bar-across') white yellowish bg using css class .selected (<div class="bar-across selected">) . when release mouse / click, homecoming original state.

fiddle html: <div id="reorder-list"> <div id="listitem_1" class="bar-across cf"><span class="handle">drag</span>item 1</div> <div id="listitem_2" class="bar-across cf"><span class="handle">drag</span>item 2</div> <div id="listitem_3" class="bar-across cf"><span class="handle">drag</span>item 3</div> </div> javascript: $(document).ready(function () { $("#reorder-list").sortable({ placeholder: "destination", forceplaceholdersize: true, handle: '.handle', update: function () { var order = $('#reorder-list').sortable('serialize'); $("#info").load("billboard-sort.php?" + order); } }); }); css: .bar-across { background:#fff; border:1px solid #ccc; margin-bottom:5px; width: 100%; } #reorder-list div .handle { cursor: move; padding:0; float:left; background:#0c6; padding: 10px; } .destination { background:#1c5dbb; width: inherited; } .selected { background:#ff0; } /* clearfix ============================================================================ */ /* clearfix */ .cf:after { content:"."; display:block; height:0; clear:both; visibility:hidden; } .cf { display:inline-block; }

have events start , stop in sortable api. using them, can add together or remove desired class to/from current, dragged element. access possible via

$(ui.item).dostuff();

where ui of course of study sec of event callback parameter.

javascript jquery html css sortable

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -