In jQuery drag and drop how can I identify a source element and change it's color? -
the code below copies (drag , drop) li 1 column keeping original li in place. trying color orginal li, in orginal column, after copy know have used.
this line find hardcoded id in source column , change it's color can't figure out how make 'input1' variable can used on selected line.
$(ident).parent().find('#input1').addclass('highlight');
i have tried variations 'event.srcelement' can't select 1 line variable.
my code:
$( "#available > li" ).draggable({ revert: 'invalid' connecttosortable: '#selected', containment: '#drag_container', helper: 'clone', start: function(ui, event) { dragged = $(this).attr('id'); draggedx = $(this).attr('class'); } }); $( "#selected" ).droppable({ drop: function(event, ui) { var ident = "#" + dragged; $(ident).parent().find('.classname').addclass('highlight'); $(ui.draggable).clone().appendto( ); } });
html:
<li id="item1" class="lineclass"><input type="text" id="input1" class="classname" name=\"1" value="item 1"></li> <li id="item2" class="lineclass"><input type="text" id="input2" class="classname" name=\"2" value="item 2"></li> </pre>
css: .highlight{background-color: yellow;font-color:green;}
edit - i'm trying fix html formatting
Comments
Post a Comment