Simple application example of the ATTR () method

Source: Internet
Author: User

The ATTR () method sets or returns the attribute value of the selected element. The working method varies according to different parameters of this method. Returns the attribute value of the selected element.

Page code:

HTML:

<Form action = "xxxxxx" method = "Post" id = "buy_form">

<Input type = "hidden" id = "paymethod" name = "paymethod" value = "directpay">

<Ul class = "NCC-payment-list">

<Li payment_code = "allstarpay" paymethod = "directpay"> ccccccc </LI>

</Ul>

</Form>

JS:

<SCRIPT type = "text/JavaScript">
$ (Function (){
$ ('. NCC-payment-List> li'). On ('click', function (){
$ ('# Paymethod'). Val ($ (this). ATTR ('paymethod '));
 
});

});
</SCRIPT>

After clicking the Li option on the page, directpay will assign the value of the Li label property paymethod to the input label with ID as paymethod.


Simple application example of the ATTR () method

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.