javascript - showing alert when drag and drop matching is correct with html css js -
i followed tutorial on internet on drag , drop, using js function:
function draguser(user, event) { event.datatransfer.setdata('user', user.id); } function dropuser(target, event) { var user = event.datatransfer.getdata('user'); target.appendchild(document.getelementbyid(user)); }
and div/id/elements modified this:
<div id="unassigned" ondrop="dropuser(this, event)" ondragenter="return false" ondragover="return false"> names: <a draggable="true" class="user" id="banana" ondragstart="draguser(this, event)">banana</a> <a draggable="true" class="user" id="newyork" ondragstart="draguser(this, event)">new york</a> <a draggable="true" class="user" id="london" ondragstart="draguser(this, event)">london</a> <a draggable="true" class="user" id="ant" ondragstart="draguser(this, event)">ant</a> <a draggable="true" class="user" id="melon" ondragstart="draguser(this, event)">melon</a> <a draggable="true" class="user" id="cow" ondragstart="draguser(this, event)">cow</a> </div> <div id="fruit" ondrop="dropuser(this, event)" ondragenter="return false" ondragover="return false"> fruit </div> <div id="animal" ondrop="dropuser(this, event)" ondragenter="return false" ondragover="return false"> animal </div> <div id="city" ondrop="dropuser(this, event)" ondragenter="return false" ondragover="return false"> city </div>
to live demo put on jsfiddle here --> http://jsfiddle.net/skinnytotoro/njdyj/1/
now want add alert when sorting/ drag , drop matching correct (like, name belong correct category) there alert saying "all matched. welldone! :)" (below table or around box)
or when 1 or names belong in wrong category, there's alert shows text-warning "almost right. keep trying!"
and question is.. code or js function have add make it? (the alert thingy)
Comments
Post a Comment