Saturday, November 3, 2012

changing tag attributes with jquery

changing tag attributes with jquery


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


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 gives
Hello 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 gives
Hello 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 gives
Hello 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. This
var a = 'Hello world!';
document.write(a.indexOf('w'))
gives 6. If the same character occurs more than once, this method gives the first occurrence. So






CheatSheet 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

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



http://ago.tanfa.co.uk/css/cribsheet/crib02.html







Ultimate CSS Cheat Sheet


http://www.addedbytes.com/cheat-sheets/css-cheat-sheet/

Given the number of possible selectors in CSS, it is no wonder some people often become confused. Mixing up ID and Class selectors is easy enough, without throwing sibling, child, attribute and language selectors into the mix. This section of the cheat sheet lists selectors and shows which element(s) those selectors would apply to.


Pseudo-selectors are used when defining styles for elements that either do not exist, or are in a particular state. This section lists various of the pseudo-selectors.
Please note - I have left the :before and :after pseudo-selectors off this list, as I felt generated content was too complex to add to this sheet and still define in a way that made that area of the sheet usable.

http://slodive.com/freebies/css-cheat-sheets/

How to stop Chrome from opening pdfs in the browser?

How to stop Chrome from opening pdfs in the browser?


http://superuser.com/questions/30850/stop-pdfs-from-displaying-inside-google-chrome

a probably faster way to do the same thing: go to chrome://plugins (in firefox, that would be about:plugins), and disable the acrobat reader plugin – Babu Aug 23 '10 at 13:24

chrome://plugins
Disable everything in the list that handles opening of PDF, even this
Foxit Reader Plugin for Mozilla - Version: 2, 0, 0, 1102 (Disabled)
Foxit Reader Plug-In For Firefox and Netscape