Skip to main content

Posts

Showing posts from February, 2015

Smooth Scrolling To Internal Links With jQuery

jQuery allows you change the way you interact with your website with very little code. jQuery has an animate function which allows you to animate anything that jQuery does, including scrolling. Animate scrolling creates a better effect to the visitor than to just job to a place on the page. There are many websites that will use internal links to jump to different parts of the page this is done by using a # and then the element id in the anchor tag. < a href = " #services " > Jump to services </ a > < div id = " services " > </ div > Doing the above creates a link that will move the page to the services div when you click it. But it jumps to this position and if it's far down the page it's not the nicest effect to the visitor. It's better if you can actually scroll to this position to help the visitors see where this is positioned. In jQuery if you set an animation on the scroll event then it creates a scrolling...

Count characters/sms using jQuery

HTML: <textarea name = "message" value = "" id = "message" ></textarea> <p> <span id = "remaining" > 160 characters remaining </span> <span id = "messages" > 1 message(s) </span> </p> jQuery: $ ( document ). ready ( function (){ var $remaining = $ ( '#remaining' ), $messages = $remaining . next (); $ ( '#message' ). keyup ( function (){ var chars = this . value . length , messages = Math . ceil ( chars / 160 ), remaining = messages * 160 - ( chars % ( messages * 160 ) || messages * 160 ); $remaining . text ( remaining + ' characters remaining' ); $messages . text ( messages + ' message(s)' ); }); }); See jsFiddle example. Ref:  http://stackoverflow.com/questions/4705185/count-characters-sms-using-jquery