jquery - How to clear an effect to apply another and then use an if/else if no draggable option is selected? -


i'm beginner in js/jquery. goal change text of $("#feelingstext") depending on plan dragged dropped box. have figured out how change text each of plans picked, can't figure out how change text if no plan dragged & dropped. should call in dragged function or use replace method?

i'm trying figure out how clear previous effect. if "greatplan" chosen $("#feelingstext") should blind, if "badplan" chosen, text should shake, , if no plan chosen, text should bounce.

thank in advance help.

html:

<div id="leftwrapper">  <div id="greatplan" class="ui-widget-content, draggable">     <p id="center">great plan!</p> </div>      <br>      <div id="badplan" class="ui-widget-content, draggable">         <p id="center">bad plan!</p>     </div> </div>       <div id="droppable" class="ui-widget-header">         <p id="center">drop plan here</p>     </div>    <button type="button" id="button" value="show feelings">     show feelings</button>      <div class="toggler">         <div id="effect" class="ui-widget-content ui-corner-all">             <p>             <h1><p id="feelingstext">how feeling?</p></h1>             </p>         </div>        </div> 

jquery:

var greatplan = $("#greatplan"); var badplan = $("#badplan");  $( ".draggable" ).draggable();  $( "#droppable" ).droppable({      drop: function( event, ui ) {          if (ui.draggable.attr("id") == "greatplan")         {             $( )             .addclass( "ui-state-highlight" )             .find( "p" )             .html( "great plan picked!" );         }          if (ui.draggable.attr("id") == "badplan")         {             $( )             .addclass( "ui-state-highlight" )             .find( "p" )             .html( "bad plan picked!" );         }       $("#button").click(function runeffect(){          var callback = function()         {             settimeout(function()             {                 $( "#effect" ).removeattr( "style" ).fadein();             }, 100 );         }          var options = [];          if (ui.draggable.attr("id") == "greatplan"){                 $( "#effect" ).stop();                 $( "#effect" ).effect( "blind", options, 1000, callback );                 $("#feelingstext").text('i'm great!').css('color', 'green');                 }          else if (ui.draggable.attr("id") == "badplan"){                 $( "#effect" ).stop();                 $( "#effect" ).effect( "shake", options, 1000, callback );                 $("#feelingstext").text('pretty bad!').css('color', 'red');                 }         else {             $("#feelingstext").text('i\'m not sure.');             $( "#effect" ).effect( "bounce", options, 1000, callback );             } 


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -