How to preview selected image in input type=”file” in popup using jQuery? [duplicate]

Demo HTML: <form id=”form1″ runat=”server”> <input type=”file” id=”imgInp” /> <img id=”blah” src=”#” alt=”your image” /> </form> jQuery function readURL(input) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function (e) { $(‘#blah’).attr(‘src’, e.target.result); } reader.readAsDataURL(input.files[0]); } } $(“#imgInp”).change(function(){ readURL(this); }); Reference

Infinite scrolling with React JS

Basically when scrolling you want to decide which elements are visible and then rerender to display only those elements, with a single spacer element on top and bottom to represent the offscreen elements. Vjeux made a fiddle here which you can look at: jsfiddle. Upon scrolling it executes scrollState: function(scroll) { var visibleStart = Math.floor(scroll … Read more

Non-Standard Attributes on HTML Tags. Good Thing? Bad Thing? Your Thoughts?

I am a big fan of the proposed HTML 5 solution (data- prefixed attributes). Edit: I’d add that there are probably better examples for the use of custom attributes. For instance, data that a custom application will use that have no analogue in standard attributes (eg. customization for event handlers based on something that can’t … Read more

CSS vertically align floating divs

You’ll have no luck with floated elements. They don’t obey vertical-align. You need display:inline-block instead. http://cssdesk.com/2VMg8 Beware! Be careful with display: inline-block; as it interprets the white-space between the elements as real white-space. It does not ignores it like display: block does. I recommend this: Set the font-size of the containing element to 0 (zero) … Read more