To implement a table's interlaced color change effect
$ ("tr"). each (function (i) {this.style.backgroundcolor=[' #ccc ', ' #fff '][i%2]})
Mouse move in Remove color ()
$(". Contenttr "). Hover (function () {
c = This.style.backgroundColor;
This.style.backgroundColor = ' #8F8FBD '
}, function () {
This.style.backgroundColor = C;
});
Let div grow bigger and smaller
$ (function () {
$ ("div"). css ({"width": "100px", "height": "100px", "Background": "Blue")
});
var defaults = $ ("div");
var multiple = 1.2;
var time = setinterval (function () {
Changediv (defaults, multiple);
if (Defaults.width () > 1000) {
multiple = 0.8;
}
if (Defaults.width () < 100) {
multiple = 1.2;
}
}, "1000");
});
function Changediv (defaults, multiple) {
$ (defaults). CSS ({
Width:function (Index, value) {
return parsefloat (value) * multiple;
},
Height:function (Index, value) {
return parsefloat (value) * multiple;
}
});
}
Start animation
$ ("#go"). Click (function () {
$ (". Block"). Animate ({left: ' +200px '}, 5000);
});
Stop animation When you click the button
$ ("#stop"). Click (function () {
$ (". Block"). Stop ();
});
The selected line changes color, the last time you select the Cancel color
$ ("table. Contenttr "). Click (function () {
$ (this). addclass ("AVB"). Siblings (). Removeclass ("AVB");
UserID = $ (this). attr ("userid");
});
Gets the value of RAD loaded into radio
$ ("Input[name= ' statics '][value=" +data[0]. Role status + "]"). attr ("Checked", true);
Determine which Rad is selected
$ (". Radclass"). each (function () {
if ($ (this). attr ("checked")) {
radval=$ (This). Val ();
}
})
First 7 digits of mobile phone number
if ($ (". Photo_text"). Text (). Replace (/\s+/g, ""). Length = = 7) {}
CheckBox Select all Reverse Selection
function Checkall () {
var a = $ (": CheckBox"). Get (0). checked;
$ (": checkbox:gt (0)"). each (function () {
this.checked = A
//});
$ (": Checkbox:not (#ckbAll)"). each (function () {
this.checked = A
});
}
Check Chinese
function Check ()
{
Get form Content
var str = document.frm1.txt1.value;
var reg =/[\u4e00-\u9fa5]/;
if (Reg.test (str))
{
Alert ("appears in Chinese");
}
}
Check mailbox
function Check ()
{
var str = document.frm1.txt1.value;
Define the regular of the mailbox
var reg =/^[0-9a-za-z][email protected][0-9a-za-z]+[\.] {1} [0-9a-za-z]+[\.]? [0-9a-za-z]+$/;
if (!reg.test (str))
{
Alert ("The mailbox format is wrong! ");
}
}
Remove spaces
function Fun ()
{
var str = document.frm1.txt1.value;
var reg =/^\s+|\s+$/g;
Document.frm1.txt1.value = Str.replace (Reg, "");
}
Complex mode (string needs to be escaped)
var regex=new Regexp ("^\\d+$"); escape character
Regex.test ("123asd1212"); False
Write a regular (without escaping) between double slashes
var regex=/^\d+$/;
Regex.test ("123213"); True
Questions about getting elements to animate and simple regular expression validation