How to zoom image to make it fit to width of div

There is common problem when display image in web page, the width of the image size may too big to fit into the page. Suppose there are two columns float in a div, the left float will display an image, the right float will show text.

How to copy text from Chrome Console to file using javascript

Consider this problem, you find a list of links on a web page, and you want get its URL and link address and save them to a file. If there are only several links, you can get them by right clicking the mouse on the link and copy link address or select the link text to copy the link .

How to toggle partially show and hide of DOM element without jQuery

Some DOM elements are visually annoying, for example a long list, we may want to only show a small part of the element, and expand to full length when the mouse is hovering on it. Its a simple script, we want the smallest javascript footprint, we don't use jQuery. With some decent micro pieces of javascript snippet, wen can .

How to set breakpoint for JQuery event handler in Chrome DevTool Event Listeners

Find out which and where an event is register by jQuery can be tricky. Select the element in Elements panel in DevTool in Chrome and select Event Listeners tab in the right side the the panel. You can only locate the javascript code inside jQuery. And all event point to the same location in jQuery. What you actually see .

What is closure in Javascript and how to use it

Closure is widely used in Javascript, I should say closure is used almost everywhere in Javascript. The closure is the corner stone of several widely used design pattern in Javascript. For a Javascript developer you will use closure in you day to day programming job.

Javascript function hoisting confusion

I was looking at code like this

And suddenly I feel confusing about the function defined in obj var literal definition. Its accessing the obj var's properties inside the function which is also a part of the objection definition(at least it looks like so).

An example of using Hogan.js template engine

point. So what is the fastest way to get a template engine work. I will suggest Hogan.js works ... Need a template engine? You will need it at some ... and npm , type this command to get Hogan.js npm install hogan.js [A simple template] Hogan.js ... with nodejs. Let's have a quick tour about Hogan.js. [Get Hogan.js] If you have installed nodejs

How to list properties of object in Javascript

This is a task that looks easy at first sight, but when you start to actually do it, things becomes a little bit complex.

The naive way is a simple for in loop.

How to use querySelector the built in CSS selector API in Javascript

Since the ubiquitous of jQuery's usage, many of you may not know there are some built in CSS selector APIs in javascipt core.

The are querySelector and querySelectorAll. When you don't have jQuery support, you can use them .

How to add input fields dynamically with jQuery example

In many applications especially HTML form, users need to add items dynamically. For example, user want to submit URLs and their description to share it. User may have variable number of links to submit, the fixed number of input fields will be inconvenient.

This post shows how to implement add and remove input fields dynamically with jQuery. Our example also support multiple items that need to be added dynamically by provide customized field type.

This post shows how to implement add and remove input fields dynamically with jQuery. Our example also .

1 2 3 Next Page