…
In questo utile tutorial vedremo come ridimensionare tutte le immagini presenti all’interno di una pagina o in uno specifico div con il conosciutissimo framework jQuery!
$(window).bind("load", function() { // IMAGE RESIZE $('#product_cat_list img').each(function() { var maxWidth = 120; var maxHeight = 120; var ratio = 0; var width = $(this).width(); var height = $(this).height(); if(width > maxWidth){ ratio = maxWidth / width; $(this)…
…
In questo semplicissimo tutorial vedremo come generare dei numeri casuali tra due numeri interi.
Per fare quanto detto utilizzeremo la funzione math.random che permette di generare numeri casuali.
var lower = 2; var higher = 10; var randomNum = Math.round(Math.random() * (higher - lower)) + lower; …
…
In questo semplice ma utile tutorial imparerete come creare una finzione che formatta un prezzo in Javascript.
function formatMoney(number){ var format_money = ""; while (parseInt(number) > 999) { format_money = "," + number.slice(-3) + format_money; number = number.slice(0, -3); } return number + format_money; } …
Nel tutorial di oggi imparerete come effettuare un grab dei Tweets utilizzando Javascript.
function getTweets(handle, tweetHash) { // Create a ul for the Twitter statuses: var twitter_nod = jQuery(' <ul id="twitter-feed"></ul> ').insertAfter("#tweets"); var maxTweets = 3; // Get & parse json object: var JSONCallback = function(data) { var html = ''; var count = 0; $.each(data, function(i,item) { var content_str = item.text; var content_created = item.created_at; if (item.text.toLowerCase…
…
…