Microsoft Ajax library cheat sheet (3): domelement class

Source: Internet
Author: User

 

The original cheat sheet (PDF version) is here to download: http://aspnetresources.com/downloads/ms_ajax_library_cheat_sheets1.zip

Original copyright statement:

Copyright (c) 2004-2006, Milan negovanhttp: // www. aspnetresources. comall rights reserved. redistribution and use in source and binary forms, with or withoutmodification, are permitted provided that the following conditionsare met: * redistributions of source code must retain the above copyrightnotice, this list of conditions and the following disclawing. * redistributions in binary form must reproduce the above copyrightnotice, this list of conditions and the following disclawing inthe documentation and/or other materials provided with thedistribution. * The name of the author may not be used to endorse or promote productsderived from this software without specific prior written permission. this software is provided by the copyright holders and contributors "as is" and any express or implied warranties, including, but not limitedto, the implied warranties of merchantability and fitness for a participant purpose are disclaimed. in no event shall the copyright owner must be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence orotherwise) arising in any way out of the use of this software, even ifadvised of the possibility of such damage.

 

NOTE: If [s] is marked as a static method, it can be used without instantiating an object.

 

[S] getelementbyid (ID, element)

Search for elements of a specific ID in the element. If no element is specified, the default value is document.

 
VaRArticle = SYS. UI. domelement. getelementbyid ('Article');
 
VaRHeading = SYS. UI. domelement. getelementbyid ('Heading', Article)
 
// Note: 'Article' is an instance of SYS. UI. domelement
 
VaRBTN = SYS. UI. domelement. getelementbyid ('<% = Submit. clientid %>');
 
// Note: 'submit 'is an ASP. NET button Server Control

 

[S]$ Get (ID, element)

SYS. UI. domelement. getelementbyid.

 
VaRArticle = $ get ('Article');
VaRHeading = $ get ('Heading', Article)
 
// Note: 'Article' is an instance of SYS. UI. domelement
 
VaRBTN = $ get ('<% = Submit. clientid %>');
 
// Note: 'submit 'is an ASP. NET button Server Control

 

[S]Addcssclass (element, classname)

Apply the specified CSS class to this element.

 
SYS. UI. domelement. addcssclass ($ get ('Heading'),'Highlight');

 

[S]Containscssclass (element, classname)

Determines whether the specified CSS class is applied to the element.

VaRHeading = $ get ('Heading', Article)
 
VaRIshighlighted = SYS. UI. domelement. containscssclass (heading,'Highlight');

 

[S]Removecssclass (element, classname)

Removes the specified CSS class from this element.

 
VaRHeading = $ get ('Heading', Article)
 
SYS. UI. domelement. removecssclass (heading,'Highlight');

 

[S]Togglecssclass (element, classname)

If the CSS class has been applied to the element, remove it; otherwise, add it.

 
VaRHeading = $ get ('Heading', Article)
VaRIshighlighted = SYS. UI. domelement. togglecssclass (heading,'Highlight');

 

[S]Getlocation (element)

Obtain the absolute position of the element relative to the upper left corner of the browser, and the distance from the visible area of the page is also calculated.

 
VaRArticle = $ get ('Article');
 
VaRPosition = SYS. UI. domelement. getlocation (Article );
 
VaRX = position. X, Y = position. Y;

 

[S]Setlocation (element, x, y)

Set the position of an element relative to the upper left corner of its positioning element. A positioning element refers to the ancestor element whose position (non-static value) is applied recently to the element.

 
VaRMenu = $ get ('Menu');
SYS. UI. domelement. setlocation (menu, 200, 50 );

 

[S]Getbounds (element)

Obtain the absolute position and length and width of an element. The returned object includes the following attributes:

    1. X, Y: gets the absolute position of the element relative to the upper left corner of the browser, which is the same as SYS. UI. domelement. getlocation.
    2. Width: the width of the element, including border, padding, and scroll.
    3. Height: the height of an element, including border, padding, and scroll.
 
VaRArticle = $ get ('Article');
 
VaRBounds = SYS. UI. domelement. getbounds (Article );
 
SYS. Debug. tracedump (bounds,'Article position and size');
 
/*
 
Article position and size {SYS. UI. bounds}
 
X: 50
Y: 200
 
Height: 268
 
Width: 368
 
*/

Note that the width and height contain border, padding, and scroll. Therefore, for an element of 300*200 pixels, 20 pixel border, and 14 pixel padding, the "width" and "height" will be 368*268 pixels.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.