Training in Web Technologies Blog

Click Once and Unbind

Have something happen on a click event, but only once! Unbind the click handler after the element has been clicked once. $(‘#my-selector’).bind(‘click’, function() { $(this).unbind(‘click’); alert(‘Clicked and unbound!’); }); Also see Ben’s comment below...

Better Responsive Images Using Multiple Backgrounds

.bg-image { width: 100%; /* default background-position */ background-position: center center; /* lt ie 8 */ -ms-background-position-x: center; -ms-background-position-y: center; /* scale proportionately */ background-size: cover; /* IE8 workaround – http://louisremi.github.io/background-size-polyfill/ */ -ms-behavior: url(/backgroundsize.min.htc);...

Different Ways To Format CSS

Formatting has nothing whatsoever to do with how the CSS functions. These are merely aesthetic choices by the coder. But that’s not to say formatting isn’t important. That would be like saying the choice...

Swapping Out Text, Five Different Ways

It’s a common need in web apps: you click something and the text of the thing you just clicked changes. Perhaps something simple like a “Show” button that swaps to “Hide”, or “Expand Description”...

Centering Percentage Width/Height Elements

If you know the exact width/height of an element, you can center it smack dab in the middle of its parent element easily with this classic trick: top and left set to 50% and negative...

How to use fonts using CSS3 with fontface?

The CSS3 @font-face Rule Before CSS3, web designers had to use fonts that were already installed on the user’s computer. With CSS3, web designers can use whatever font he/she likes. When you have found/bought...

Book your train tickets from mobile through SMS

Now Book your train tickets using Mobile Phone, anywhere and anytime WITHOUT using Internet connection. Train passengers will be able to use their mobile phones to book tickets through a simple text-messaging-based-SMS facility or...

CSS3 Transitions

With CSS3, we can add an effect when changing from one style to another, without using Flash animations or JavaScripts. Internet Explorer 10, Firefox, Chrome, and Opera supports the transition property. Safari requires the...

How to use CSS3 Multiple Columns?

CSS3 Multiple Columns With CSS3, you can create multiple columns for laying out text – like in newspapers! In this chapter you will learn about the following multiple column properties: column-count column-gap column-rule Browser...

How to use CSS3 borders?

CSS3 Borders With CSS3, you can create rounded borders, add shadow to boxes, and use an image as a border – without using a design program, like Photoshop. In this chapter you will learn...

Web Design: A Guide To CSS3 Pseudo-Classes

The pseudo-classes are used to target elements without having to add extra classes, attributes or ID; that is why it is called in that way, pseudo-class. Throughout our previous posts, we havecovered a few new CSS3 pseudo-classes, including :not, :before and :after, :first-of-typeand we also...

Wrapping Content In Shapes With CSS3

How To Use Shape-Inside The shape-inside allows us to form four shapes: rectangle, circle, polygon, and ellipse, though the shape that seems to work at the moment, is only the polygon. In the following example, we will...

How to make responsive images using CSS and JSON

Current proposed responsive image solutions require that you inline media query values into HTML tags. <picture> <source media=”(min-width: 45em)” src=”large.jpg”> <source media=”(min-width: 18em)” src=”med.jpg”> <source src=”small.jpg”> <img src=”small.jpg” alt=””> </picture> This is a problem...

Windows 8 Hints and tips to increase the quality

Windows 8 has been with us for over half a year now, and if you’re used to previous versions of Windows then you’re going to notice that quite a bit has changed. In fact,...

How to make Underline Individual Words using jQuery?

jQuery $(‘h1’).each(function() { var words = $(this).text().split(‘ ‘); $(this).empty().html(function(){ for(i = 0; i < words.length; i++){ if(i == 0){ $(this).append(‘<span>’ + words[i] + ‘</span>’); } else { $(this).append(‘ <span>’ + words[i] + ‘</span>’); }...

Working with Attributes

Setting Single Attribute $(“img”).attr(“src”, “http://cdn.css-tricks.com/images/banner.jpg”); Setting Single Attribute (with function) $(“div”).attr(“id”, function (arr) { return “div-id” + arr; }) Setting Multiple Attributes $(“img”).attr({ src: “http://cdn.css-tricks.com/images/banner.jpg”, title: “banner”, alt: “banner” }); Getting Attribute var $source...

Learn to Like Your Job

As vice president of a Los Angeles film-production company in the 1980s, Ronald Kaufman had nearly everything that he’d ever wanted in a job — great pay, friendly co-workers and interesting work coordinating product...

New Resume Rules

Q: I am a senior executive and haven’t looked for a job in more than 10 years. How can I make my résumé more current by today’s standards? –Boston, Mass. Getty Images A: While the résumé...

Didn’t Get the Job? You’ll Never Know Why

You aced the interview, your résumé sings, but in the end, you didn’t get the job. Chances are, you’ll never know why. It is a painful conundrum of the job search process: Rejected candidates...

jQuery finish() Method

<!DOCTYPE html> <html> <head> <script src=”//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js”> </script> <script> $(document).ready(function(){ $(“#start”).click(function(){ $(“div”).animate({height:300},3000); $(“div”).animate({width:300},3000); }); $(“#complete”).click(function(){ $(“div”).finish(); }); }); </script> </head> <body> <p> <button id=”start”>Start Animation</button> <button id=”complete”>Finish Current Animation</button> </p> <div style=”background:#98bf21;height:100px;width:100px”> </div> </body> </html>

jQuery clearQueue() Method

<!DOCTYPE html> <html> <head> <script src=”//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js”> </script> <script> $(document).ready(function(){ $(“#start”).click(function(){ $(“div”).animate({height:300},1500); $(“div”).animate({width:300},1500); $(“div”).animate({height:100},1500); $(“div”).animate({width:100},1500); }); $(“#stop”).click(function(){ $(“div”).clearQueue(); }); }); </script> </head> <body> <button id=”start”>Start Animation</button> <button id=”stop”>Stop Animation</button> <br><br> <div style=”background:red;height:100px;width:100px;”> </div> </body> </html>

jQuery delay() Method

<!DOCTYPE html> <html> <head> <script src=”//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js”> </script> <script> $(document).ready(function(){ $(“button”).click(function(){ $(“#div1”).delay(“slow”).fadeIn(); $(“#div2”).delay(“fast”).fadeIn(); $(“#div3”).delay(800).fadeIn(); $(“#div4”).delay(2000).fadeIn(); $(“#div5″).delay(4000).fadeIn(); }); }); </script> </head> <body> <p>This example sets different speed values for the delay() method.</p> <button>Click to fade in...

jQuery – The noConflict() Method

What if you wish to use other frameworks on your pages, while still using jQuery? jQuery and Other JavaScript Frameworks As you already know; jQuery uses the $ sign as a shortcut for jQuery....

jQuery – Dimensions

With jQuery, it is easy to work with the dimensions of elements and browser window. jQuery Dimension Methods jQuery has several important methods for working with dimensions: width() height() innerWidth() innerHeight() outerWidth() outerHeight() jQuery...

jQuery Effects – Sliding

The jQuery slide methods slides elements up and down. jQuery Sliding Methods With jQuery you can create a sliding effect on elements. jQuery has the following slide methods: slideDown() slideUp() slideToggle() jQuery slideDown() Method...

jQuery Callback Functions

A callback function is executed after the current effect is 100% finished. jQuery Callback Functions JavaScript statements are executed line by line. However, with effects, the next line of code can be run even...