Simple application example of the attr () method and application example of the attr Method

Source: Internet
Author: User

Simple application example of the attr () method and application example of the attr Method

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.



The problem of jquery-202 for attr Method

Use $ ('selector '). prop ("checked"); // obtain the checked value of the selected item;
$ ('Selector '). prop ("checked",' "true"); // you can specify the checked value of the selected item;
This is enough.

Numerical Calculation Method: Simple Application of MATLAB

In the first question, we can consider using the fzero function. In the example, x = fzero (@ sin, 3) gets pi.

The second question should not directly use the interpolation function interp1. It is best to use linear fitting (the knowledge of physics tells us that the resistance value and temperature are linearly related) before interpolation calculation, use all data points to minimize the error. In essence, the interp1 function only uses two recent data points. Once there is a large error in the measurement of these two data points, the error of the output value will not be satisfactory, linear fitting can use all five data points to make it more scientific when the linear relationship between resistance and temperature is known.

T = [20.5, 32.7, 51.0, 73.0, 95.7];
R = [765,826,873,942,103 2];
P = polyfit (t, R, 1 );
R_60 = polyval (P, 60 );
R_60

Result:
R_60 =
906.0212
 

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.