Posts

Showing posts with the label html

Interesting Javascript Facts

Wishes to the web development world :) In the past 2 to 3 months I had chance to know about loads & loads of innovative JS Libraries All of them made me wonder "Is there a thing that we can't do in JS?" I wish to share some facts which got me mad in to this language & very beginnerish ;) What is {} + []? As soon as I saw this question my reply was "[object Object]" But the real answer was 0 :O Couldn't get any good guess on this, so posted @stackoverflow And I myself couldn't believe I missed it :P {} => Empty Block Scope & +[] => 0 So, cometh thy answer :) Some more of the same kind {} + {} = NaN [] + [] = "" [] + {} = "[object Object]" Why obj === +obj? I found this @ the source of Backbone.js I was wondering why should they check JS number type in such a way? Once again I got back to Stackoverflow The reply once again stunned me up :D It was to save the...

HTML Input Place Holder

A Simple way to implement placeholder in a Input Field. Although HTML 5 by default provides placeholders[placeholder attribute], it falls short in Cross Browser Compatibility Construct A Simple Form Username: Let's Implement Placeholders Now [With jQuery] Change the HTML To HTML: Username Result Username Apply CSS and Overlay placeholder over Input Element CSS: .place-holder { position:relative; left:-245px; color:#AAA; z-index:1; } .name-field { width:250px; background:#FFF; z-index:0; } Result Username Handle Focus and Blur Event :) jQuery: $().ready(function () { function hideHolder() { $('.place-holder').hide(); } function showHolder() { if($('.name-field').val() == '') { $('.place-holder').show() } } $('.name-field').focus(hideHolder); $('.name-field').blur(showHolder); $('.place-holder').click(function () { $('.name-field').trigger('focus'); }); }); ...