The code is
"I just want a simple HTML-code converter!".
If you write some text in your HTML code,characters like < or > are not shown correctly because those characters are reserved for the code. There are plenty of good sites showing all the HTML codes but I just wanted to find the corresponding code quick and easy thus I've created this converter.
After I've made the converter look nice with CSS I've coded the converting system with JavaScript. Get the text in the input field(id "input") with the code
var x =document.getElementById("id of the input field").value;
Don't forget to put value at the end otherwise the information of the input field will not be stored. Now, we want to output the corresponding HTML code of the character you've typed in. Anykind of number or alphabet is called a "string". A character is a also a string so we look at the JavaScript string methods.
charCodeAt()
That's the string method we've been looking for! Because it converts strings to HTML codes.Write
variable of the input field.charCodeAt()
to output the corresponding code.
Now, let's look at the button. It is invoked through 2 events which are mousedown and mouseup. If you click the mouse which is the "mousedown" event, the code is outputed and the border style of the button is changed to inset so that the button looks like it's pushed down.
I've you finish clicking which is the "mouseup" event, the border style is changed to its initial style which is outset. Finito, now we've created a simple HTML-Code converter.
If you write some text in your HTML code,characters like < or > are not shown correctly because those characters are reserved for the code. There are plenty of good sites showing all the HTML codes but I just wanted to find the corresponding code quick and easy thus I've created this converter.
After I've made the converter look nice with CSS I've coded the converting system with JavaScript. Get the text in the input field(id "input") with the code
var x =document.getElementById("id of the input field").value;
Don't forget to put value at the end otherwise the information of the input field will not be stored. Now, we want to output the corresponding HTML code of the character you've typed in. Anykind of number or alphabet is called a "string". A character is a also a string so we look at the JavaScript string methods.
charCodeAt()
That's the string method we've been looking for! Because it converts strings to HTML codes.Write
variable of the input field.charCodeAt()
to output the corresponding code.
Now, let's look at the button. It is invoked through 2 events which are mousedown and mouseup. If you click the mouse which is the "mousedown" event, the code is outputed and the border style of the button is changed to inset so that the button looks like it's pushed down.
I've you finish clicking which is the "mouseup" event, the border style is changed to its initial style which is outset. Finito, now we've created a simple HTML-Code converter.