jscolor is a color picker javascript
it lets u make an input type="text" into a color picker, just by adding the class .color to the <input tag>
1
it inside a function
(the input tag element, referenced as this) is an OBJECT with property .color which is the chosen color in the colorpicker
2
therefore, you can pass
product_text_color.attr('class', 'color'); // the input box has been made into a jquery object first
// attach color picker to it by adding a class .color to it
{'color': product_text_color.val()}
programatically passing an OBJECT with prop .color to a function:
since you can't directly get the colorpicker, USE JQUERY TO DO IT, and this is the way how.
and then the fn taking this OBJECT as arg, references it like this: colorObj.color
Refer to next post:
jquery get the value of a select box
Saturday, November 3, 2012
css baseline
css baseline
http://www.w3schools.com/cssref/pr_pos_vertical-align.asp
img
{
vertical-align:text-top;
}
http://www.w3schools.com/cssref/pr_pos_vertical-align.asp
CSS vertical-align Property
img
{
vertical-align:text-top;
}
| text-bottom | The bottom of the element is aligned with the bottom of the parent element's font |
changing tag attributes with jquery
changing tag attributes with jquery
http://api.jquery.com/attr/
http://api.jquery.com/attr/
<p>
Once there was a <em title="huge, gigantic">large</em> dinosaur...</p>
The title of the emphasis is:<div></div>
<script>
var title = $("em").attr("title");
concatenating strings in javascript
concatenating strings in javascript
http://www.quirksmode.org/js/strings.html
http://www.quirksmode.org/js/strings.html
You can even use numbers or calculations, like:
document.write (a + 3*3 + b);
Now we concatenate string
a, then the result of 3*3, treated as a string for the occasion, and then b, which givesHello world!9I am a JavaScript hacker.
Watch out if you want to add numbers. This
document.write (a + 3+3 + b);
concatenates four strings:
a, 3, 3 and b, because + in this context meansconcatenate strings, not add, and givesHello world!33I am a JavaScript hacker.
Use brackets if you want to add 3 and 3 before making the string.
document.write (a + (3+3) + b);
concatenates
a, the result of 3+3 and b and givesHello world!6I am a JavaScript hacker.
indexOf
One of the most widely used automatical methods is
indexOf. Each character has an index number, giving its position in the string. Note that the first character has index 0, the second one index 1 etc. So the index of 'w' in string a is 6.
Using
indexOf we can read out the index number of a character. Put the.indexOf('') behind the string name and put the character you're looking for between the quotes. Thisvar a = 'Hello world!';
document.write(a.indexOf('w'))
gives
6. If the same character occurs more than once, this method gives the first occurrence. SoCheatSheet for Javascript language finer points, for-loop in Javascript
finer points, ...or indeed what you should know about the JavaScript Language right from the start, even.
http://bonsaiden.github.com/JavaScript-Garden/
Read when you have time, and want some leisure reading.
Learnt this, today:
http://bonsaiden.github.com/JavaScript-Garden/
Javascript Cheatsheet website
xxx();
function xxx() { //this function will fly to the top, document scope,
//even if function call is before this fn definition, still works.
}
var xxx = function () {} // if the fn call is before this fn def, will errormsg: xxx is 'undefined'
for namespacing purpose, function is the only struct that limits scope of its internal variables:
var Bill = {
xxx : function () {
// only function are scope boundary
// ...but only fly to here.
function aaa() {
// so this function aaa() won't be able to fly to the top...
}
(var x;)
for (a=0;a<2;a++) {
var x = 123; // this var will fly out of this for loop, as if belonging to
//the function xxx's scope. (as if declared as above line in parentheses)
}
}
}
Bill.xxx()
Q. why need to wrap in $() the whole block?
how to iterate over a list in javascript
http://ajaxian.com/archives/how-many-ways-can-you-iterate-over-an-array-in-javascript
THE CANONICAL WAY:
http://forums.asp.net/t/1040956.aspx/1
for(var i = 0; i < YourList.length; i++)
{
var yourObject = YourList[i];
//Do whatever you want.
}
http://www.openjs.com/articles/for_loop.php
http://bonsaiden.github.com/JavaScript-Garden/
Read when you have time, and want some leisure reading.
Learnt this, today:
http://bonsaiden.github.com/JavaScript-Garden/
Javascript Cheatsheet website
xxx();
function xxx() { //this function will fly to the top, document scope,
//even if function call is before this fn definition, still works.
}
var xxx = function () {} // if the fn call is before this fn def, will errormsg: xxx is 'undefined'
for namespacing purpose, function is the only struct that limits scope of its internal variables:
var Bill = {
xxx : function () {
// only function are scope boundary
// ...but only fly to here.
function aaa() {
// so this function aaa() won't be able to fly to the top...
}
(var x;)
for (a=0;a<2;a++) {
var x = 123; // this var will fly out of this for loop, as if belonging to
//the function xxx's scope. (as if declared as above line in parentheses)
}
}
}
Bill.xxx()
Q. why need to wrap in $() the whole block?
how to iterate over a list in javascript
http://ajaxian.com/archives/how-many-ways-can-you-iterate-over-an-array-in-javascript
THE CANONICAL WAY:
http://forums.asp.net/t/1040956.aspx/1
for(var i = 0; i < YourList.length; i++)
{
var yourObject = YourList[i];
//Do whatever you want.
}
http://www.openjs.com/articles/for_loop.php
More Optimized
var len=arr.length;
for(var i=0; i<len; i++) {
var value = arr[i];
alert(i =") "+value);
}
Thursday, November 1, 2012
CSS defaults, CSS user-agent defaults (you reset these globally/localized.)
1
Names of defaults:
overflow: hidden;
white-space: normal;
text-overflow: clip;
2
"show user-agent CSS" in FireBug. can't turn off this styles from within firebug,
have to either
1. use a global css reset sheet
2. or localized override, for example, p margin.
CSS @ sitepoint , CODEBURNER for FIREBUG
CSS @ sitepoint
sitepoint CODEBURNER for FIREBUG
http://tools.sitepoint.com/codeburner/
http://reference.sitepoint.com/css/syntax
General Syntax and Nomenclature
In this Section
- Statements
- At-rules
- Rule Sets
- Selectors
- Declaration Blocks
- Declarations, Properties, and Values
- CSS Comments
- CSS Identifiers
- CSS Escape Notation
- CSS Syntax Errors
http://ago.tanfa.co.uk/css/cribsheet/crib02.html
Subscribe to:
Posts (Atom)