Notes by James
Displaying keyword search results 1 - 10
Created by James on February 02, 2012 16:00:15
Last update: February 02, 2012 16:00:15
Video for Everybody seems to be a generic way to embed video in a web page, even without flash. This code snippet comes from that site.
<!-- first try HTML5 playback: if serving as XML, ...
Created by James on January 16, 2012 10:05:10
Last update: January 16, 2012 10:06:13
There are two ways to get the submit button:
Use the :submit selector (note the space between the form name and :submit ):
$('#the-form-id :submit')
Use attribute selector (also, space between form id and attribute selector):
$('#the-form-id [type="submit"] ')
// or
$(...
jQuery recommends the latter if you are concerned about performance:
Because :submit is a jQuery extension and not part of the CSS specification, queries using :submit cannot take advantage of the performance boost provided by the native DOM querySelectorAll() method. For better performance in modern browsers, use [type="submit"] instead.
Created by James on October 25, 2011 19:44:30
Last update: October 25, 2011 19:45:40
jQuery automatically maps HTML5 custom data attributes to data storage associated with the data() method. Here's an example:
<html>
<head>
<script type="text/javascript"...
Created by James on May 01, 2011 20:46:46
Last update: May 01, 2011 20:46:46
Unlike languages such as Python or PHP, an empty array in JavaScript is true . The proper way to test for an empty array is to check the length attribute:
// empty array is true
var anArray = [];
if ...
Created by James on April 04, 2011 19:41:51
Last update: April 04, 2011 19:41:51
Use the nodeName attribute to get the name of the HTML tag, tagName is not recommended .
<!DOCTYPE html>
<html>
<head>
<title>jQu...
Created by James on July 04, 2009 16:30:40
Last update: January 11, 2011 21:21:59
If you are looking for a solution for a progress bar, I direct you to the following resources: Bare Naked App provides a simple and elegant solution based on pure CSS with two images. You control the percentage of completion through the background-position attribute of the CSS. HTML:
<img src="/images/percentImage.png" alt="... CSS: img.percentImage { background: white url(/imag... Images: (percentImage.png) (percentImage_back.png) WebAppers extended the above solution with JavaScript. They also added several colored images: JQuery UI has a built-in progress bar widget. However, if you want to get to understand some of the foobar needed to get CSS to work (in general) through this example, stay with me for the rest of this note. Initially I was thinking, a progress bar should be easy: just make...
Created by James on May 24, 2009 20:14:25
Last update: January 11, 2011 20:07:38
In the following HTML code, I attached an inline handler to the text field input and added two event handlers with addEventListener / attachEvent . Both IE and Firefox called the inline handler first. But the order in which the added event handlers were called are different between IE and Firefox (IE calls attached_click2 first). Further, if I add the same event handler multiple times, IE calls the handler the same number of times. But Firefox only calls the same handler once, no matter how many times it was added.
<html> <body> <form> Input: <input type="... You can attach an event handler to an HTML element either inline , with JavaScript , or by calling addEventListener (DOM level 2), or attachEvent (IE specific). When you...
Created by James on April 17, 2009 01:15:01
Last update: January 11, 2011 20:05:36
You can still turn the checkbox or radio button on and off even when the readonly attribute is set:
<html>
<body>
<form method="GET">
<inp...
Created by James on January 04, 2011 16:22:43
Last update: January 05, 2011 13:43:06
The jQuery doc says: If you wish to use any of the meta-characters (such as !"#$%&'()*+,./:;?@[\]^`{|}~ ) as a literal part of a name, you must escape the character with two backslashes: \\ . So what are these meta-characters ? According to the CSS specification : In CSS, identifiers (including element names, classes, and IDs in selectors) can contain only the characters [a-zA-Z0-9] and ISO 10646 characters U+00A0 and higher, plus the hyphen (-) and the underscore (_); These meta-characters are the printable characters in the ASCII but outside the range allowed by CSS identifiers. They must be escaped, with two backslashes. Why two backslashes? Because one backslash is consumed by JavaScript, and with only one backslash in place, no backslash is passed to jQuery...
Created by James on October 21, 2010 19:48:36
Last update: October 21, 2010 19:50:43
Use the in operator to enumerate over an object's properties:
Use the in operator to list all properties of an object
Call the hasOwnProperty function to determine if the property is a direct attribute of the current object, i.e., not some attribute defined somewhere up the prototype chain.
Test code (copy and paste to the JavaScript Executor ):
function BaseClass() {
this.p1 = 'parent.p1...
Note that intrinsic attributes such as constructor , prototype are not listed by the in operator.