1var myInt = parseInt("10.256"); //10
2var myFloat = parseFloat("10.256"); //10.256
1// Method - 1 ### parseInt() ###
2var text = "42px";
3var integer = parseInt(text, 10);
4// returns 42
5
6// Method - 2 ### parseFloat() ###
7var text = "3.14someRandomStuff";
8var pointNum = parseFloat(text);
9// returns 3.14
10
11// Method - 3 ### Number() ###
12Number("123"); // returns 123
13Number("12.3"); // returns 12.3
14Number("3.14someRandomStuff"); // returns NaN
15Number("42px"); // returns NaN
1let theInt = parseInt("5.90123"); //5
2let theFloat = parseFloat("5.90123"); //5.90123
1var myString = "869.99"
2var myFloat = parseFloat(myString)
3var myInt = parseInt(myString)
1$("#link").attr("href"); // get an attribute
2$("#link").attr("href",'https://htmlg.com'); // set attribute
3$("#link").attr({
4"href" : "https://htmlg.com", // setting multiple attributes
5"title" : "HTML Editor"
6});
7$("#link").attr("href", function(i, origValue){
8return origValue + "/help"; // callback function gets and changes the attribute
9});
10