jquery Programming Glossary: math.round
Uploading Image to Amazon s3 with HTML, javascript & jQuery with Ajax Request (No PHP) http://stackoverflow.com/questions/11240127/uploading-image-to-amazon-s3-with-html-javascript-jquery-with-ajax-request-n evt if evt.lengthComputable var percentComplete Math.round evt.loaded 100 evt.total document.getElementById 'progressNumber'..
How to disable browser or element scrollbar, but allow scrolling with wheel or arrow keys? http://stackoverflow.com/questions/1326570/how-to-disable-browser-or-element-scrollbar-but-allow-scrolling-with-wheel-or-a var scrollTop this .scrollTop this .scrollTop scrollTop Math.round delta script This is a quick mockup you'd have to adjust the..
Randomize a sequence of div elements with jQuery http://stackoverflow.com/questions/1533910/randomize-a-sequence-of-div-elements-with-jquery elems this.children childElem elems.sort function return Math.round Math.random 0.5 this.remove childElem for var i 0 i elems.length.. elems this.children childElem elems.sort function return Math.round Math.random 0.5 this.remove childElem for var i 0 i elems.length..
Select 5 random elements http://stackoverflow.com/questions/1764160/select-5-random-elements randomElements jQuery li .get .sort function return Math.round Math.random 0.5 .slice 0 5 At this point you have 5 DomElements..
Turn a number into star rating display using jQuery and CSS http://stackoverflow.com/questions/1987524/turn-a-number-into-star-rating-display-using-jquery-and-css sizes add one of these rows before the var size row val Math.round val 4 4 To round to nearest quarter val Math.round val 2 2 To.. row val Math.round val 4 4 To round to nearest quarter val Math.round val 2 2 To round to nearest half HTML span class stars 4.8618164..
Center an Image vertically and horizontally using CSS http://stackoverflow.com/questions/2478434/center-an-image-vertically-and-horizontally-using-css '#imgContainer' .width set img position this.style.top Math.round div_h h 2 'px' this.style.left '50 ' this.style.marginLeft Math.round..
How can I determine if an image has loaded, using Javascript/jQuery? http://stackoverflow.com/questions/263359/how-can-i-determine-if-an-image-has-loaded-using-javascript-jquery var new_width . . . var new_height . . . #photo .width Math.round new_width #photo .height Math.round new_height Update Thanks.. . . . #photo .width Math.round new_width #photo .height Math.round new_height Update Thanks for the suggestions. There is a risk.. var new_width . . . var new_height . . . #photo .width Math.round new_width #photo .height Math.round new_height javascript..
preload with percentage - javascript/jquery http://stackoverflow.com/questions/4999703/preload-with-percentage-javascript-jquery
Increase CSS brightness color on click with jquery/javascript? http://stackoverflow.com/questions/5833624/increase-css-brightness-color-on-click-with-jquery-javascript if max multiplier 255 multiplier multiplier 230 1 var r Math.round red multiplier var g Math.round green multiplier var b Math.round.. multiplier 230 1 var r Math.round red multiplier var g Math.round green multiplier var b Math.round blue multiplier if r 255 r.. red multiplier var g Math.round green multiplier var b Math.round blue multiplier if r 255 r 255 if g 255 g 255 if b 255 b 255..
Get element -moz-transform:rotate value in jQuery http://stackoverflow.com/questions/8270612/get-element-moz-transformrotate-value-in-jquery ' ' 0 .split ' ' var a values 0 var b values 1 var angle Math.round Math.atan2 b a 180 Math.PI else var angle 0 return angle 0 angle..
Safari: Absolutely positioned DIVs not moving when updated via DOM http://stackoverflow.com/questions/9471038/safari-absolutely-positioned-divs-not-moving-when-updated-via-dom 'rotate ' this.angle 180 Math.PI 1 'deg ' 'left' Math.round this.xPos 'px' 'top' Math.round this.yPos 'px' I've added position.. Math.PI 1 'deg ' 'left' Math.round this.xPos 'px' 'top' Math.round this.yPos 'px' I've added position relative to the body... I..
Uploading Image to Amazon s3 with HTML, javascript & jQuery with Ajax Request (No PHP) http://stackoverflow.com/questions/11240127/uploading-image-to-amazon-s3-with-html-javascript-jquery-with-ajax-request-n BEFORE YOU SEND xhr.send fd Helper functions function uploadProgress evt if evt.lengthComputable var percentComplete Math.round evt.loaded 100 evt.total document.getElementById 'progressNumber' .innerHTML percentComplete.toString ' ' else document.getElementById..
How to disable browser or element scrollbar, but allow scrolling with wheel or arrow keys? http://stackoverflow.com/questions/1326570/how-to-disable-browser-or-element-scrollbar-but-allow-scrolling-with-wheel-or-a here div script #example .bind mousewheel function ev delta var scrollTop this .scrollTop this .scrollTop scrollTop Math.round delta script This is a quick mockup you'd have to adjust the numbers since for me this scrolls a bit slowly. keyCode reference..
Randomize a sequence of div elements with jQuery http://stackoverflow.com/questions/1533910/randomize-a-sequence-of-div-elements-with-jquery childElem return this.each function var this this var elems this.children childElem elems.sort function return Math.round Math.random 0.5 this.remove childElem for var i 0 i elems.length i this.append elems i jQuery Here's a Working Demo ... childElem return this.each function var this this var elems this.children childElem elems.sort function return Math.round Math.random 0.5 this.remove childElem for var i 0 i elems.length i this.append elems i jQuery HTML div class band div..
Select 5 random elements http://stackoverflow.com/questions/1764160/select-5-random-elements get 5 random elements from a jQuery selection no need of plugins randomElements jQuery li .get .sort function return Math.round Math.random 0.5 .slice 0 5 At this point you have 5 DomElements that have been selected randomly from all the LIs that jQuery..
Turn a number into star rating display using jQuery and CSS http://stackoverflow.com/questions/1987524/turn-a-number-into-star-rating-display-using-jquery-and-css If you want to restrict the stars to only half or quarter star sizes add one of these rows before the var size row val Math.round val 4 4 To round to nearest quarter val Math.round val 2 2 To round to nearest half HTML span class stars 4.8618164 span.. star sizes add one of these rows before the var size row val Math.round val 4 4 To round to nearest quarter val Math.round val 2 2 To round to nearest half HTML span class stars 4.8618164 span span class stars 2.6545344 span span class stars 0.5355..
Center an Image vertically and horizontally using CSS http://stackoverflow.com/questions/2478434/center-an-image-vertically-and-horizontally-using-css
How can I determine if an image has loaded, using Javascript/jQuery? http://stackoverflow.com/questions/263359/how-can-i-determine-if-an-image-has-loaded-using-javascript-jquery in a quarter second setTimeout adjust_photo_size 250 return var new_width . . . var new_height . . . #photo .width Math.round new_width #photo .height Math.round new_height Update Thanks for the suggestions. There is a risk of the event not being.. 250 return var new_width . . . var new_height . . . #photo .width Math.round new_width #photo .height Math.round new_height Update Thanks for the suggestions. There is a risk of the event not being fired if I set a callback for the.. loaded REAL_WIDTH #photo .width REAL_HEIGHT #photo .height var new_width . . . var new_height . . . #photo .width Math.round new_width #photo .height Math.round new_height javascript jquery image share improve this question Either add an event..
preload with percentage - javascript/jquery http://stackoverflow.com/questions/4999703/preload-with-percentage-javascript-jquery
Increase CSS brightness color on click with jquery/javascript? http://stackoverflow.com/questions/5833624/increase-css-brightness-color-on-click-with-jquery-javascript 1.5 multiplier 1.9 if it gets to white move away a bit if max multiplier 255 multiplier multiplier 230 1 var r Math.round red multiplier var g Math.round green multiplier var b Math.round blue multiplier if r 255 r 255 if g 255 g 255 if b 255.. gets to white move away a bit if max multiplier 255 multiplier multiplier 230 1 var r Math.round red multiplier var g Math.round green multiplier var b Math.round blue multiplier if r 255 r 255 if g 255 g 255 if b 255 b 255 return rgb r g b When the.. multiplier 255 multiplier multiplier 230 1 var r Math.round red multiplier var g Math.round green multiplier var b Math.round blue multiplier if r 255 r 255 if g 255 g 255 if b 255 b 255 return rgb r g b When the dark div is clicked the new color..
Get element -moz-transform:rotate value in jQuery http://stackoverflow.com/questions/8270612/get-element-moz-transformrotate-value-in-jquery if matrix 'none' var values matrix.split ' ' 1 .split ' ' 0 .split ' ' var a values 0 var b values 1 var angle Math.round Math.atan2 b a 180 Math.PI else var angle 0 return angle 0 angle 360 angle angle1 getRotationDegrees '#myDiv' angle2 getRotationDegrees..
Safari: Absolutely positioned DIVs not moving when updated via DOM http://stackoverflow.com/questions/9471038/safari-absolutely-positioned-divs-not-moving-when-updated-via-dom moz transform' 'rotate ' this.angle 180 Math.PI 1 'deg ' 'transform' 'rotate ' this.angle 180 Math.PI 1 'deg ' 'left' Math.round this.xPos 'px' 'top' Math.round this.yPos 'px' I've added position relative to the body... I added the 'px' and rounded.. 180 Math.PI 1 'deg ' 'transform' 'rotate ' this.angle 180 Math.PI 1 'deg ' 'left' Math.round this.xPos 'px' 'top' Math.round this.yPos 'px' I've added position relative to the body... I added the 'px' and rounded down the numbers incase Safari didn't..
|