JQuery HTML () and other methods introduced _jquery
Source: Internet
Author: User
For getting the value of an element, such as an input box, we tend to use $ (' #test '). Val ();
$ (' #test ') I'm not going to say that, anyway, get this element with the ID test.
$ (' #test '). Val (), that is, to get its value, in general, any element that can be used in a form can use. val () to get the value, such as Input,textarea,select, to get their current value
and. Val (' AA '); Sets the value of the element, $ (' #test '). Val (' AA '), which is equivalent to setting the test element to a value of AA.
There are two other types of usage:. HTML (),. Text (), which is often used on div and span elements, and is typically assigned and evaluated for both elements.
The. HTML () replaces the previous. InnerHTML,. html (' test '), instead. InnerHTML = ' Test ';
These similar simplifications allow us to feel more fluid in the actual operation.
All of these methods are assigned and evaluated directly in the method name Riga parameters. Some of the values are taken by the second parameter (not quite clear ...). , such as $ (' #test '). attr (' name '), the value returned is the name in its attribute, if $ (' #test '). attr (' id ', ' test2 '), is equivalent to setting the name of the test element to test2 and then taking the value, name is Test2.
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