$.each(array, callback)
$.each([10,20],function(index,value){
alert(index+" "+value);
});
Note: index and value can be any name
$.each(object, callback);
var object = {
"color":"red",
"font-size":"10px"
};
$.each(object,function(key,value){
alert(key+" "+value);
});
Note: key and value can be any name.
JavaScript Examples
Saturday, November 1, 2014
How to use jQuery
HTML
<p>ddddddddd</p>
jQuery
$(function(){
$("p").css({"font-size":"20px"});
});
Note 1
$(function(){
});
//this is equal to document.ready
$(document).ready(function(){ });
Note 2
$(selector).action();
Note 3
one of action is css.
css({"property1":"value1","property2":"value2"});
Note 4
change $ to jQuery to avoid conflict
jQuery(function(){
jQuery("p").css({"color":"red"});
});
Note 5
jQuery starts with $ and end with ;
middle with () anonymous function
regular expression ^ means start, $ means end
<p>ddddddddd</p>
jQuery
$(function(){
$("p").css({"font-size":"20px"});
});
Note 1
$(function(){
});
//this is equal to document.ready
$(document).ready(function(){ });
Note 2
$(selector).action();
Note 3
one of action is css.
css({"property1":"value1","property2":"value2"});
Note 4
change $ to jQuery to avoid conflict
jQuery(function(){
jQuery("p").css({"color":"red"});
});
Note 5
jQuery starts with $ and end with ;
middle with () anonymous function
regular expression ^ means start, $ means end
Subscribe to:
Posts (Atom)