JQuery implements the select drop-down box to obtain the selected text, value, index, and add/delete Select Option items, jqueryoption
// Directly Save the suffix. htnl and open it in Google's browser.
The method $.prop in jquery is slightly different from the $.attr method. Prop is used in intrinsic HTML properties, while attr is often used in our custom properties.So the difference is here:The results of the Prop method are as follows:$ ("#chk1"). Prop ("checked") = = false$ ("#chk2"). Prop ("checked") = = TrueThe results of the attr method are as follows:$ ("#chk1"). attr ("checked") = = undefined$ ("#chk2"). attr ("checked") = = "true"Also co
recently work is writing jquery, in fact I did not learn the system JS, today to share with you a recent write about the check box batch processing. The check box here batch processing is the delete operation. When the Select All button is selected, the other checkboxes are all selected, and the Select all check box is generally used in the list, and all columns
JQuery implements the Select drop-down list to Select the status, jqueryselect
Scenario:
E. g.: When managing a blog post, the management of a blog post includes a column named "status", which has many statuses, such:Normal, waiting for review, deletion, etc...In this case, if you use the Select drop-down list to
jquery full selection, all-do not select, the implementation of the reverse effect code "recommended"
First: Introduce jquery
Style:
Body layout:
Implementation features:
All of the above jquery Select, all do not
Today, I read the jquery manual, a little bit more understanding of the prop () function, and a record of memory.
Prop (): Gets the value of the first element in the matching element set
Determine if the first one in the checkbox is selected:
$ (": CheckBox"). Prop ("checked"); Returns False if the first checkbox is selected to return true.
Disable and select all check boxes on the page:
$ ("
Jquery.checkboxes.zip, decompress and reference to the page using the plug-in,You don't need to talk about this! Let's take a look at the specific example below. In order to give everyone a better understanding, I directly paste the code that implements the function:Copy codeThe Code is as follows:$ ("# Myform"). toggleCheckboxes () // select all. deselect all and select inverse.$ ("# Myform"). toggleCheckb
In the construction of the site, let the check box and all the cancellation is more commonly used, the following describes how to use a sentence to solve the full selection function; In fact, it is very simple, that is, using the function of counting jquery deprecated the last piece of code in this article; Well, the method I want to introduce is finished; Well, don't smash the eggs; I'm kidding. The code is below JavaScript section: function Check
20120808 Yu Xincheng Science Park
In jquery, how do I set and obtain the select values of radio, checkbox, select, and multiple. Put it here first. If you have a deeper understanding in the future, we will continue to maintain thisArticle.
Pay attention to referencing a jquery package.
essence;I really can't restrain my inner worship, these lines of code are so beautiful.PS: Above JS Why use prop instead of attr, because: if the current input in the initialization of undefined checked attribute, then the element does not have the specified checked attribute, so. attr () will return undefined;
For HTML elements that have intrinsic properties, use the Prop method when processing.
For HTML elements our own custom DOM properties, when processing, use the Attr method.
JQuery fragment (1) Basics: select the elements to be operated, process DOM elements, and jquery Fragment
1. Basics
Jquery object set:$ (): Jquery object setObtain the elements in the jquery object set:Use the index to obtain the
jquery performs a select-All/no-select operationBut found in 1.10.0 (other versions unknown), the first two can work correctly, but the third time is not. Find the workaround later, use the$ (': CheckBox '). Prop ("Checked", this.checked);Alternative$ (': CheckBox '). attr ("Checked", this.checked);jquery high Version
DOCTYPE HTML Public "-//W3C//DTD XHTML 1.0 transitional//en" "http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd "> HTMLxmlns= "http://www.w3.org/1999/xhtml"> Head> title>Select all, do not select all, reversetitle> Scriptsrc= "Http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js">Script> Scriptlanguage= "JavaScript"type= "Text/jav
During each select operation, we always need to provide the materials. We recommend that you summarize the information and review it later.
For example,
1. Set the value to pxx.
$ (". Selector"). val ("pxx ");
2. Set text to pxx.
$ (". Selector"). find ("option [text = 'pxx']"). attr ("selected", true );
Here is the use of brackets. The equal signs in brackets are preceded by attribute names without quotation marks. In many cases, the use of br
Today in the check function, suddenly found in IE there is a select dynamic changes in the width has been shortened, tried a lot of ways are not solvedOn the internet for a long time to find a, first insert the empty option, then the assignment is OK, record, will be used in the futurevar obj = document.getElementById (' lst1 '); var opn = document.createelement ("OPTION"); Obj.appendchild (OPN); // First append opn.innertext =11;Original address: IE7
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.