Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

________________________________________________________________________________

______________________
.offset()
"Get the current coordinates of the first element, or set the coordinates of eve
ry element,
in the set of matched elements, relative to the document."
var off = $("#work").offset(); //returns object and can't be directly
accessed. so we use off.left & off.top
$("#test").html("left: " + off.left + ", top: " + off.top); // get offse
t
****************************************
$( "#demo" ).offset({ top: 10, left: 30 }); // set offset
________________________________________________________________________________
______________________
.position()
"Get the current coordinates of the first element in the set of matched elements
, relative to the offset parent."
var p = $( "p:first" );
var position = p.position();
$( "p:last" ).text( "left: " + position.left + ", top: " + position.top
);
________________________________________________________________________________
______________________
.css()
Get the value of a style property for the first element in the set of matched el
ements or set
one or more CSS properties for every matched element.
var color = $( this ).css( "background-color" );
$( "#result" ).html( "That div is <span style='color:" + color + ";'>" +
color + "</span>." );
****************************************
var styleProps = $( this ).css(["width", "height", "color", "backgroundcolor"]);
$.each( styleProps, function( prop, value ) {
html.push( prop + ": " + value );
});
$( "#result" ).html( html.join( "<br>" ) );
****************************************
$( this ).css( "color", "red" ); // set css property
$( this ).css( "width", "+=200" ); //increase width
****************************************
$( this ).css({
"background-color": "yellow",
"font-weight": "bolder"
});
****************************************
var styles = {
backgroundColor : "#ddd",
fontWeight: ""
};
$( this ).css( styles );

________________________________________________________________________________
______________________

________________________________________________________________________________
______________________

________________________________________________________________________________
______________________

You might also like