Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@bertt
Created January 6, 2013 12:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save bertt/4466846 to your computer and use it in GitHub Desktop.
Save bertt/4466846 to your computer and use it in GitHub Desktop.
TypeScript and JQuery sample
var Person = (function () {
function Person(name) {
this.name = name;
}
return Person;
})();
function greeter(person) {
return "hallo " + person.name;
}
var person = new Person("bert");
$(document).ready(function () {
var message = greeter(person);
$("#status")[0].innerHTML = message;
});
<html>
<head>
<script src="http://code.jquery.com/jquery-1.8.0.js"></script>
</head>
<body>
<script src="hello.js"></script>
<div id="status"></div>
</body>
</html>
/// <reference path="jquery.d.ts" />
class Person {
constructor(name:string)
{
this.name=name;
}
name: string;
}
function greeter (person:Person){
return "hallo "+person.name;
}
var person=new Person("bert");
$(document).ready(function(){
var message = greeter(person);
$("#status")[0].innerHTML=message;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment