RSSAll Entries in the "Javascript" Category

Traversing DOM using JavaScript

Traversing DOM using JavaScript

The HTML DOM defines a standard way for accessing and manipulating HTML documents.
The DOM presents an HTML document as a tree-structure expressed as an XML document.
DOM is a language independent API, as it can be used in Java, .NET, JavaScript and many more. I will use it with JavaScript to for my sample code provided [...]

RGB-to-Hex Conversion

RGB-to-Hex Conversion

Question is: How do I convert RGB values of a color to a hexadecimal string?
The algorithm is as follows: make sure that RGB values are in the range 0…255, convert RGB values to hex strings, and then merge the three strings. Here is a script that does this conversion:
function RGBtoHex(R,G,B) [...]

charachter validation and count for a textbox - Javascript

charachter validation and count for a textbox – Javascript

Here I have provided a solution to put a counter for a textbox, that can be updated as each character typed into the textbox. This script will also validate the maximum character length allowed for a textbox. This script will also work when anyone copy/paste the text into the textbox. Textbox can be either single [...]

Enable/Disable DIV tags through Javascript

Enable/Disable DIV tags through Javascript

Copy/Paste following javascript code snippet.
<script type="text/javascript"> function toggleAlert() { toggleDisabled(document.getElementById("content")); } function toggleDisabled(el) { try { el.disabled = el.disabled ? [...]