<!doctype html>
<head>
<title>Mobile-Web-App: jQuery</title>
<meta charset="utf-8">
<script type="text/javascript" src="http://code.jquery.com/jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
var myArray = ["A", 100, "EF", [1, 2, 3, 4]];
document.writeln("<p>myArray = " + myArray + "</p>");
$.each(myArray, function(index, value){
document.writeln("<p>index = " + index + " : value = " + value + "</p>");
});
});
</script>
</head>
<body>
</body>
</html>
Monday, April 30, 2012
jQuery: .each()
Example of using jQuery .each() function:
Wednesday, April 25, 2012
In Javascript, function can be assigned to variable
Example to to assign a Javascript function to a variable like a object.
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Mobile-Web-App: Javascript Exercise - function</title>
<script>
var func = function(i){
return i*2;
}
function test(){
info = "<p> typeof(func): " + typeof(func) + "</p>"
+ "<p> typeof(func(5)): " + typeof(func(5)) + "</p>"
+ "<p> func(5): " + func(5) + "</p>";
document.getElementById("prompt").innerHTML=info;
}
</script>
</head>
<body onload="test();">
<h1>Mobile-Web-App: Javascript Exercise - function</h1>
<div id="prompt"></div>
</body>
</html>
Tuesday, April 24, 2012
Datejs - JavaScript Date library
Datejs is an open-source JavaScript Date library.
Example:
Example:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Mobile-Web-App: Javascript Exercise - Datejs</title>
<script src="http://www.datejs.com/build/date.js" type="text/javascript"></script>
<script>
function test(){
info = "<p><b>Datejs: an open-source JavaScript Date library</b></p>"
+ "<p> Today's date: " + Date.today() + "</p>"
+ "<p> Add 5 days to today: " + Date.today().add(5).days() + "</p>"
+ "<p> Get Friday of this week: " + Date.friday() + "</p>"
+ "<p> Get March of this year: " + Date.march() + "</p>"
+ "<p> Is today Friday? " + Date.today().is().friday() + "</p>";
document.getElementById("prompt").innerHTML=info;
}
</script>
</head>
<body onload="test();">
<h1>Mobile-Web-App: Javascript Exercise - Datejs</h1>
<div id="prompt"></div>
</body>
</html>
Monday, April 23, 2012
Javascript Exercise - Date object
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Mobile-Web-App: Javascript Exercise - Date</title>
<script>
function test(){
var date = new Date();
info = "<p> date: " + date + "</p>"
+ "<p> date.getFullYear(): " + date.getFullYear() + "</p>"
+ "<p> date.getMonth() 0-11: " + date.getMonth() + "</p>"
+ "<p> date.getDate() 1-31: " + date.getDate() + "</p>"
+ "<p> date.getDay() 0-6: " + date.getDay() + "</p>"
+ "<p> date.getHours() 0-23: " + date.getHours() + "</p>"
+ "<p> date.getMinutes() 0-59: " + date.getMinutes() + "</p>"
+ "<p> date.getSeconds() 0-59: " + date.getSeconds() + "</p>"
+ "<p> date.getMilliseconds() 0-999: " + date.getMilliseconds() + "</p>";
document.getElementById("prompt").innerHTML=info;
}
</script>
</head>
<body onload="test();">
<h1>Mobile-Web-App: Javascript Exercise - Date</h1>
<div id="prompt"></div>
</body>
</html>
Javascript Exercise - Comparison: == vs ===
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Mobile-Web-App: Javascript Exercise - Comparison</title>
<script>
function test(){
info = "<p> == vs === </p>"
+ "<p> 1 == '1' " + (1 == '1') + "</p>"
+ "<p> 1 != '1' " + (1 != '1') + "</p>"
+ "<p> 1 === '1' " + (1 === '1') + "</p>"
+ "<p> 1 !== '1' " + (1 !== '1') + "</p>";
document.getElementById("prompt").innerHTML=info;
}
</script>
</head>
<body onload="test();">
<h1>Mobile-Web-App: Javascript Exercise - Comparison</h1>
<div id="prompt"></div>
</body>
</html>
FREE eBook: Programming Computer Vision with Python
The website http://www.maths.lth.se/matematiklth/personal/solem/book.html is for the upcoming computer vision book - Programming Computer Vision with Python, by Jan Erik Solem. The book is meant as an entry point to hands-on computer vision for students, researchers and enthusiasts using the Python programming language.
You can visit the eBook in PDF directly here.
You can visit the eBook in PDF directly here.
Subscribe to:
Posts (Atom)




