jQuery Make item 'flash' when clicked -
jQuery Make item 'flash' when clicked -
i have next code:
<style> .submit input, .submit { border-top: 1px solid #96d1f8; background: #b2d4eb; background: -webkit-gradient(linear, left top, left bottom, from(#9ebbce), to(#b2d4eb)); background: -webkit-linear-gradient(top, #9ebbce, #b2d4eb); background: -moz-linear-gradient(top, #9ebbce, #b2d4eb); background: -ms-linear-gradient(top, #9ebbce, #b2d4eb); background: -o-linear-gradient(top, #9ebbce, #b2d4eb); padding: 5px 10px; -webkit-border-radius: 8px; -moz-border-radius: 8px; border-radius: 8px; -webkit-box-shadow: rgba(0,0,0,1) 0 1px 0; -moz-box-shadow: rgba(0,0,0,1) 0 1px 0; box-shadow: rgba(0,0,0,1) 0 1px 0; text-shadow: rgba(0,0,0,.4) 0 1px 0; color: black; } .submithighlight { background: #ffff99; } .btnsmall { width: 15em; float: right; margin-right: 2em; margin-bottom: 1em; display: none; } </style> <script language="javascript" src="..\generic\javascript\jquery-min.js" type="text/javascript"></script> <script language="javascript" src="..\generic\javascript\jquery-ui-min.js" type="text/javascript"></script> <script language="javascript"> $(document).ready(function() { $("#sg1").click(function() { $(this).parent().switchclass('submit','submithighlight','slow').delay(2000).switchclass('submithighlight','submit','slow'); }) }) </script> <p class="submit"> <input id="sg1" class="btnsmall" type="submit" name="submit" value="sg1" style="display: inline-block;"> </p>
what trying when click button, 'flashes' original bluish yellowish , 1 time again highlight fact pressed.
the closest have got far above code, far 'flash', more stutter.
what best way go this?
i tried utilize animate, couldn't see how animate add together /remove class.
jsfiddle
you dont have have basic style rules of input set sec class, when class switched lose things padding, box-shadow, etc.
i rearranged style rules more explicitly things ( note left border on yellowish 1 because don't know want it).
#sg1 { padding: 5px 10px; -webkit-border-radius: 8px; -moz-border-radius: 8px; border-radius: 8px; -webkit-box-shadow: rgba(0,0,0,1) 0 1px 0; -moz-box-shadow: rgba(0,0,0,1) 0 1px 0; box-shadow: rgba(0,0,0,1) 0 1px 0; text-shadow: rgba(0,0,0,.4) 0 1px 0; color: black; } .submit #sg1 { border-top: 1px solid #96d1f8; background: #b2d4eb; background: -webkit-gradient(linear, left top, left bottom, from(#9ebbce), to(#b2d4eb)); background: -webkit-linear-gradient(top, #9ebbce, #b2d4eb); background: -moz-linear-gradient(top, #9ebbce, #b2d4eb); background: -ms-linear-gradient(top, #9ebbce, #b2d4eb); background: -o-linear-gradient(top, #9ebbce, #b2d4eb); } .submithighlight #sg1 { background: #ffff99; } .btnsmall { width: 15em; float: right; margin-right: 2em; margin-bottom: 1em; display: none; }
you can add together in css transitions smooth out color alter if youre feeling frisky. have initial #sg1 style rules of this:
#sg1 { padding: 5px 10px; -webkit-border-radius: 8px; -moz-border-radius: 8px; border-radius: 8px; -webkit-box-shadow: rgba(0,0,0,1) 0 1px 0; -moz-box-shadow: rgba(0,0,0,1) 0 1px 0; box-shadow: rgba(0,0,0,1) 0 1px 0; text-shadow: rgba(0,0,0,.4) 0 1px 0; color: black; transition: background 1s ease; }
jquery jquery-ui jquery-animate
Comments
Post a Comment