0

Right now I'm doing this. I want to get rid of jQuery.

var brt = $('#id').val();

I want to move to TypeScript. How can I achieve this?

KayR
  • 50
  • 9
  • `var brt = $('#id').val();` Valid JavaScript is valid TypeScript. – Heretic Monkey Apr 15 '16 at 19:17
  • I should've been more specific, sorry. I dont want to use jQuery as well. – KayR Apr 15 '16 at 19:18
  • Feel free to [edit] your question to reflect that. Honestly, you should look at [the DOM interfaces](https://developer.mozilla.org/en-US/docs/Web/API/Document_Object_Model). If you only want to know how to translate this specific code to TypeScript/DOM then it would just be the same as http://stackoverflow.com/q/3969199/215552 – Heretic Monkey Apr 15 '16 at 19:23
  • 2
    Possible duplicate of [JavaScript get input text value](http://stackoverflow.com/questions/11563638/javascript-get-input-text-value)—same as javascript: `document.getElementById("id").value` – David Sherret Apr 15 '16 at 19:27

2 Answers2

0

TypeScript isn't a replacement for jQuery, it's a superset of JavaScript.

If you want a cross-browser library that allows you to implement actions against the DOM with a single syntax, jQuery (among other frameworks) is still a great tool for that job. TypeScript can utilize jQuery, but it's not a replacement for it.

Whit Waldo
  • 4,806
  • 4
  • 48
  • 70
0

Note that Typescript is a superset of both Javascript (ES5), which is supported by most of the browsers, and new Javascript (ES6 / EcmaScript2015)

Usually Typescript is transpiled down to Javascript ES5 in order to be supported by all of the major browsers.

Thanks to that, you can get rid of jQuery library and select the DOM node by using Javascript.

let brt = document.getElementById("id").value
fbid
  • 1,570
  • 2
  • 18
  • 29