background preloader

Javascript

Facebook Twitter

Node.js

Checkbox - Get a list of checked checkboxes in a div using jQuery. Cross-Browser approach to Copy content to Clipboard with javascript. Jquery. Reference. Good practices. HIOX (JS) Javascript Tutorial - dom Radio Button Object, RadioButton events, select, checked value, function. Forms. Slideshow. Dropdown. Window. Change CSS class/style with Javascript. Okay, I'll try to explain this as simply as possible.

Change CSS class/style with Javascript.

I want to, dynamically, most likely with a javascript function, change the properties of a CSS style. Currently, I've crafted some code that will allow me to change/apply a style to a specific DIV -- targeting the ID of it. This is great... Here is a sample of the code: <! Width: 150px; height: 150px; visibility: hidden; background-color:#CCCCCC; function makeVis(divID) { document.getElementById(divID).style.visibility = "visible"; } The First Div The Second Div Make One Visible | Make Two Visible When I click 'Make One Visible' it will make 'theDivNameOne' show up.

Now here comes the part I can't figure out. I want to change the style by targetting the actual style/class that is specified in the CSS code -- not by targetting the actual DIV. Make Them ALL Visible Any DIV, SPAN, P or anything that has 'class="theStyle"' applied to it, will change... Any ideas?

Debugging

Load different stylesheet based on browser. 28 Jun, 2002 Posted by: Jennifer In: Scripts Thought I posted this here already, but I guess I didn't.

load different stylesheet based on browser

Here's a javascript to detect the user's browser, and load the appropriate stylesheet. I came up with this script because some of the css things I had once been doing were not friendly with NS. <SCRIPT language="JavaScript"> <! (ie. Javascript Kata » Advanced katas for javascripters. JavaScript Regular Expression. Regular expressions can be used in the String.replace() method to cleanup and modify user entered data or data from external sources.

JavaScript Regular Expression

This is handy for forms or when working with AJAX or XML building Web Applications. The RegExp object enables JavaScript to reformat character data with one line code where string methods would require several. Trimming Leading and trailing white space Frequently it is necessary to remove leading, trailing or both leading and trailing spaces from character data before using it in code. Select whether you want to trim the left spaces, right spaces, or both left and right space below. In each case, one of the following three functions were used. Note that the regular expression to trim both leading and trailing spaces requires the global flag g or it will only remove the leading spaces. function ltrim(str){ return str.replace(/^\s+/, ''); } function rtrim(str) { return str.replace(/\s+$/, ''); } function alltrim(str) { return str.replace(/^\s+|\s+$/g, ''); }

Adding table rows &amp; columns in JavaScript. With insertRow() method you can insert a new row at the specified position in HTML table.

Adding table rows &amp; columns in JavaScript

After row is created, use insertCell() method to insert a table cell. Wrap this methods in JavaScript functions and you have code to dynamically add new rows and columns in the HTML table. Please try to click the buttons below ... When you click the "Add row" button, appendRow() function is called. Function is simple, table row is inserted at the last position, and loop iterates through table cells in the first row. CreateCell() also sets class attribute (needed for the red and green background color) to the DIV element.