Inho wa Injoo wa Injae Family 1 2 Natures Guestbook PumStories PhotoStories Facebook SongPyoung Jelyan Youtube


  jun(2013-02-11 22:49:11, Hit : 1751, Vote : 382
 javascript basic

001)

var numOfShoes = '2';
var numOfSocks = 4;

var totalItems1 = numOfShoes + numOfSocks;
var totalItems2 = +numOfShoes + numOfSocks;
var totalItems3 = Number(numOfShoes) + numOfSocks;

document.write(totalItems1+','+totalItems2+','+totalItems3);

24,6,6


002)

message = message + ' ' + name;
->message += ' ' + name;


003)

properties[properties.length] = 'bold';
->properties.push('bold');

properties.push('bold', 'italic', 'underlined'); // multi

properties.unshift('bold'); // beginning of an array

var p = [0,1,2,3];
var removedItem = p.pop(); // remove the item from the end of the array
= [0,1,2]

var p = [0,1,2,3];
var removedItem = p.shift(); // remove the item from the beginning.
= [1,2,3]


004)

document.body.style.backgroundColor='green';


005)

var luckyNumber = prompt('What is your lucky number?','');
luckyNumber = parseInt(luckyNumber); // parseInt() converts the value to an integer
                                                         // if input isn't a number then it will provide a special
                                                         // JavaScript value, NaN (¡°not a number.¡±)
if (isNaN(luckyNumber)) {
luckyNumber = prompt('Please, tell me your lucky number.','');
}


006)

function printToday() {
var today = new Date();
document.write(today.toDateString()); //Sun May 11 2013
}

007)

var TAX = .08; // 8% sales tax
function calculateTotal(quantity, price) {
var total = quantity * price * (1 + TAX);
var formattedTotal = total.toFixed(3); //¼Ò¼öÁ¡ 3ÀÚ¸®
return formattedTotal; // returns the value
}

body
document.write('Total: $' + calculateTotal(2, 16.95));


008)

document.getElementById('banner')      // <div id=¡°banner¡±>
document.getElementsByTagName(¡®a¡¯) //selects all anchor tags on a page





13   ÇÁ·Î±×·¥ °Ë»ö¼øÀ§  jun 2012/09/27 2586 386
12   Æä¼ÒÈ­ ¹®Á¦(Peso Problem)  °í¸¸ÀÌ 2011/02/21 3303 493
11   ÀÎÅÍ³Ý °Ë»ö ¹æ¹ý  °í¸¸ÀÌ 2013/11/21 2082 356
10   ÀÌÇ׸ðÇü  jun 2010/07/29 3152 491
9   wedding rehersal&true wed.in jeju island [2]  irene 2010/06/06 1966 326
8   NTLDR is missing  °í¸¸ÀÌ 2013/09/14 1916 397
7   jquery basic  °í¸¸ÀÌ 2013/09/14 4177 449
  javascript basic  jun 2013/02/11 1751 382
5   iPtime Ncubic Driver  °í¸¸ÀÌ 2013/09/14 2332 431
4   hi [2]  °í¸¸ÀÌ 2010/05/16 2157 436
3   eclipse...  °í¸¸ÀÌ 2013/09/14 2686 411
2   cp760 printer driver  jun 2012/11/04 2325 378
1   Best Global Brands 2012  jun 2012/10/03 2571 371

1
 

Copyright 1999-2024 Zeroboard / skin by zero