Created
December 5, 2013 04:54
-
-
Save esperia/7800344 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title></title> | |
<script type="text/javascript" src="/js/libs/jquery-1.10.2.min.js"></script> | |
<script src="/js/jstest.js"></script> | |
</head> | |
<body> | |
<h1>hogehoge</h1> | |
<div id="wrap">wrap</div> | |
<div class="myclass">a</div> | |
<div class="myclass">b</div> | |
</body> | |
</html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function basic() { | |
var number = 1; | |
console.log(number); // 1 | |
var text = 'text'; | |
console.log(text); // "text" | |
var obj = { | |
foo: 'bar', | |
hoge: { | |
fuga: 'aaa', | |
fuga2: 'bbb', | |
} | |
}; | |
console.log(obj); // [Object] | |
console.log(obj.foo); // "bar" | |
console.log(obj.foo == obj['foo']); // true | |
var array = [ | |
'a', | |
1, | |
{ | |
foo: 'bar' | |
} | |
]; | |
console.log(array); // ['a', 1, { foo: 'bar' }] | |
function func(value) { | |
var f = 1 + value; | |
return f; | |
} | |
console.log(func(2)); // 3 | |
var varFunc = function func2(value) { | |
var f = 1 + value; | |
return f; | |
}; | |
console.log(varFunc(2)); // 3 | |
var insData = [{ | |
name: 'hoge', | |
value: 'fuga' | |
}, { | |
name: 'foo', | |
value: 'bar' | |
}]; | |
console.log(insData[0]); // Object | |
for (var i = 0; i < insData.length; i++) { | |
var o = insData[i]; | |
var name = o.name; | |
var value = o.value; | |
console.log(name, value); // 'hoge', 'fuga' | |
} | |
} | |
//basic(); | |
$(function() { | |
var wrapEl = $('#wrap'); | |
$('<p>').appendTo( wrapEl ); // p要素を生成して、 id="wrap" な要素へ追加 | |
// class="myclass" な要素全てにCSSを当てる。 | |
var classEl = $('.myclass').css({ | |
'background-color': '#ff0000' // 背景を#ff0000(赤色)へ | |
}); | |
console.log(classEl); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment