css
test
CSS (name) gets the style named name
$ ("#a"). CSS ("color") will get the color value red in the style, ("#a"). CSS ("background") will get blue
CSS (prop) prop is a hash object that is used to set a large number of CSS styles
$ ("#b"). CSS ({color: "Red", Background: "Blue"});
The final effect is
test
,{color:" Red ", Background:" Blue "},hash object, Color is key," red "is value,
CSS (key, value) is used to set a separate CSS style
$ ("#b"). CSS ("Color", "red"); the final effect is
test
four: JavaScript processing
$.browser () to determine the browser type, return Boolen value
$ (function () {
if ($.browser.msie) {
Alert ("This is an IE browser");}
else if ($.browser.opera) {
Alert ("This is an opera browser");}
})
When the page is loaded to determine the type of browser, the types that can be judged are MSIE, Mozilla, Opera, Safari
$.each (obj, fn) obj is an object or array, and FN is the function that executes sequentially on OBJ, noting that the $ () is distinguished. each ()
$.each ([0,1,2], function (i) {alert ("Item #" + i + ":" + This);});
0,1,2 as a parameter and passed into function (i), respectively
$.each ({name: "John", Lang: "JS"}, function (i) {alert ("Name: + i +", Value: "+ this);
{Name: "John", Lang: "JS"} is a hash object, which in turn passes each set of objects in the hash to the function
$.extend (obj, prop) expands the first object with the second object
var settings = {validate:false, limit:5, Name: "foo"};
var options = {validate:true, name: "Bar"};
$.extend (settings, options);
After execution, the settings object is {validate:true, limit:5, Name: "Bar"}
You can use the following function to test
$ (function () {
var settings = {validate:false, limit:5, Name: "foo"};
var options = {validate:true, name: "Bar"};
$.extend (settings, options);
$.each (settings, function (i) {alert (i + "=" + This);});
})
$.grep (ARRAY,FN) filters the array by the function FN, passing the elements in the array to FN,FN must return a boolen, such as FN return true, will be filtered
$ (function () {
var arr= $.grep ([0,1,2,3,4], function (i) {return i > 2;});
$.each (arr, function (i) {alert (i);});
})
We can look at the execution $.grep after the array [0,1,2,3,4] becomes [0,1]
$.merge (first, second) two parameters are arrays, expel the second array with the same one, then combine two numbers and
$ (function () {
var arr = $.merge ([0,1,2], [2,3,4])
$.each (arr, function (i) {alert (i);});
})
You can see that the result of ARR is [0,1,2,3,4]
$.trim (str) remove spaces at both ends of the string
$.trim ("Hello, How are"?) "The result is" Hello, how are you? "