Welcome To Snipplr
Everyone's Recent JavaScript Snippets
- All /
- JavaScript /
- HTML /
- PHP /
- CSS /
- Ruby /
- Objective C
Quick example to show how 'this' depends on how the function in which you called it in was being invoked. From jQuery in Action.
1
1273
posted 17 years ago by 1man
An example of how to extent the jQuery objects to include our own methods.
0
1600
posted 17 years ago by 1man
Usage: onmouseout='if (isMouseLeaveOrEnter(event, this)) YourActionHere();' onmouseover='if (isMouseLeaveOrEnter(event, this)) YourOtherActionHere();'
1
1597
posted 17 years ago by Winkyboy
Para realizar validaciones en Javascript rápidamente. Requiere que en la etiqueta metamos un onSubmit="return checkform(this);" . Este trozo de código es para dos campos input con nombres campo1 y campo2.
0
853
posted 17 years ago by betacontinua
If you have a complex function you may need to pass it lots of arguments. Instead of having to remember how many you need to pass, and passing 'null' for un needed arguments, pass the function an object.
Now you can set the defaults inside the fun...
0
1418
posted 17 years ago by 1man
I got this code from http://blog.vishalon.net/Post/57.aspx
The actual two methods required are
function doGetCaretPosition (ctrl) {
var CaretPos = 0;
// IE Support
if (document.selection) {
ctrl.focus ();
var Sel = document.select...
3
5236
posted 17 years ago by arunpjohny
/* ---===[ EXAMPLE ]===--- */
var TT = new AssociativeArray();
TT.add("k-1", "Value 1");
TT.add("k-2", "Value 2");
TT.add("k-3", "Value 3");
TT.add("k-4", "Value 4");
alert(TT.to_string());
1
1042
posted 17 years ago by vbert
/* --==[ EXAMPLE ]==--
var colors = new AArray();
colors.add("k01", {bk:"#fff",tk:"b",it:"hello"});
var oC = colors.get("k01");
var tT = '';
for(K in oC) tT += "[" + K + "]: " + oC[K] + "\n";
tT += "\n\n";
tT += oC.bk + "\n";
tT += oC...
1
1555
posted 17 years ago by vbert
(c) copyright Stephen Chapman, 1st Jan 2005.
Example:
alert('http://'+uri.dom+uri.path+'/folder/file.js');
0
1228
posted 17 years ago by oxisound
This makes it easy to retrieve certain value from a url with different values appended to it.
0
1542
posted 17 years ago by iTony
This would make IE treat the hover element in whichever tag you implemented.
0
879
posted 17 years ago by iTony
curvyCorners is a free JavaScript program that will create on-the-fly rounded corners for any HTML DIV element, that look as good as any graphically created corners.
3
1747
posted 17 years ago by jonhenshaw
Will toggle an element's style.visibility, or set it to visible/hidden as selected
0
1252
posted 17 years ago by martinkas
Then, your code should look like this ...
$(document).ready(function() {
$("dt > a").click(function(){
$(this).parent().nextUntil('dt').toggle();
return false;
});
});
0
1210
posted 17 years ago by thecrumb
#modal would be the bodyID of your modal window. I use jqmodal so it strips out all the header tags, and takes your body ID and turns it into a div.
2
1329
posted 17 years ago by kristin
Found this quick little bit of code on the Google jQuery discussion group. It simply fades the background image of a link you have hovered over to a certain color, then fades it back to the original color.
4
1426
posted 17 years ago by 1man
This is to prevent a form from being inadvertently submitted.
0
1319
posted 17 years ago by ecavazos