A long-troubled question:If only$ (' input[type=checkbox] '). attr (' checked ', true);//Select All $ (' input[type=checkbox] '). attr (' checked ', false);//Not selectedCan only be the first full selection and the full selection of valid, after the failure.Later I found this to be done:Select $ (' #checkbox1 '). attr
December 21, 2015 10:52:51 MondayTarget, click on the current Checbox to determine whether the current checkbox is selected after the click.Html:Js:1 var checkall = $ ("#contracts_checkall"). attr (' checked '); 2 var checkall_value1 = $ ("#contracts_checkall"). Val (); 3 var checkall_value2 = $ (' #contracts_checkall '). Is (': Checked '); 4 Console.log (checkall); 5 Console.log (checkall_value1); 6 Con
?.. Paging this is fine with me, but this check box is next to the page and it will be refreshed.
Two scenarios
Scenario 1- - -1. A separate container (DIV) for each page.
...
2. When loading a new page, first check that the page has been loaded, such as loading page 4
The code is only indicative if ($ ('. Page-4 ', '. Content '). Length > 0) { $ ('. Page ', '. Content '). Hide (); $ ('. Page-4 ', '. Content '). Show (); else { page4 = Render_page (Load_page (4));//Get
------------------------------------------------------------------------------------------For a small example, jquery implements the Select All/Cancel/reverse selection of a checkbox in a form[Email protected] -----------------------------------------------------------------------------------------The above uses the event: Click, event Toggle: Toggle, Form element match:
$ ("input"). attr ("checked"); type= "checkbox" value= "1"/>This is a little problem today.And then always output undefined and checked;Checked it out a lot, and didn't find any problems.And then find the information on the Internet, mostly.if ($ "#xxx". attr ("checked") = = "true")if ($ ("#xxx"). attr ("checked") = =true)Or is thisAlert ( $ ("input"). attr
To use jquery to get a textual description of the checkbox, use the following statement.
$ ("#knowfrom"). Find ("input[type= ' checkbox ']:checked"). Siblings (). text ();
Example Two
$ ("#knowfrom"). Next (). Text ()
See a full detailed example
j
This article mainly introduces jquery to get the checkbox value and submit it in post mode. If you need a friend, you can refer to the following nonsense and directly provide the Code:
The Code is as follows:
$ Data = $ _ POST ['data'];$ Arr = json_decode ($ data );Var_dump ($ arr );$ A = array (1, 2, 4 );Foreach ($ a as $ v ){?> ">}?>Script$ ('. But_delet_choice'). click (function (){// Obtain the
Jquery version: 1.3.2
CopyCode The Code is as follows:
Jquery. ATTR gets/Sets object attribute values, such:Copy codeThe Code is as follows: $ ("input [name = 'chk _ list']"). ATTR ("checked"); // read the status of all objects whose names are 'chk _ List' (whether or not selected)$ ("Input [name = 'chk _ list']
JQuery version: 1.3.2Copy codeThe Code is as follows: JQuery. attr gets/Sets object attribute values, such:Copy codeThe Code is as follows:$ ("Input [name = 'chk _ list']"). attr ("checked"); // read the status of all objects whose names are 'chk _ List' (whether or not selected)$ ("Input [name = 'chk _ list']"). attr
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
Jquery obtains the values of text, areatext, radio, checkbox, select, and other operations;1. Suppose we have the following page:
Input Type="Text" Name="Textname" ID="Text_id" Value="">
2. The following describes how to obtain various values in form;
Function Get_form_value(){
/* Obtain the value of text. areatext */
var textval =$ (
1. To get the selected value, three methods are available:$ (' input:radio:checked '). Val ();$ ("input[type= ' Radio ']:checked"). Val ();$ ("Input[name= ' rd ']:checked"). Val ();2. Set the first radio to the selected value:$ (' Input:radio:first '). attr (' checked ', ' checked ');Or$ (' Input:radio:first '). attr (' checked ', ' true ');Note: attr ("Checked", ' checked ') = attr ("Checked", ' true ') =
JQuery API:Each (callback): Executes a function with each matching element as the context.: Checked: Matches all selected selected elements (Checkboxes, radio boxes, etc., excluding option in select)ls|//js get check box valuevarobj = Document.getelementsbyname ("Interest");//selects all objects name= "Interest", returns the arrayvars="';//If you define VAR s in this way, the variable s will be assigned a null value by default for(varI=0; i){ if(O
This code has only one time to select all, all the effects of the third click Checkall will not have any effect
$ ("#checkall"). Click (function () {
$ (' input[name= ' Check "]). attr (" Checked ",this.checked);
});
Use prop to achieve the desired results per click
$ ("#checkall"). Click (function () {
$ (' input[name= ' Check "]). Prop (" checked ",this.checked);
});
Because ch
Using JavaScript to make a set of checkpoints on the page select/cancel all, the logic is very simple, and the implementation of code is not too difficult syntax. However, jquery is simpler to implement and the code is concise and incisive!
Jquery version: 1.3.2
Code
Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->
Tag: Property object code length Select string Set attribute LogSelect/Cancel a set of check boxes/* * * Select/Cancel a set of check boxes * @param checkallid all Checkboxid * @param objname */function Selectgroup (checkallid,objname) { $ (' input[name= ' +objname+ ') '). Prop (' Checked ', $ ("#" +checkallid). Prop (' Checked ')); }Gets the value of a selected set of check boxesfunction Getcheckedval (checkboxname) { var checkedvals
jquery version: 1.3.2
Copy Code code as follows:
Jquery.attr Gets/Sets the property value of an object, such as:
Copy Code code as follows:
$ ("Input[name= ' chk_list ']"). attr ("checked"); Reads the status of all name ' Chk_list ' objects (checked)
$ ("Input[name= ' chk_list ']"). attr ("Checked", true); Sets the c
The 2012 European Cup "death group" team is:1, the first and second team to qualify, so to limit only two items to be selected.var len = $ ("Input[name= ' Nation ']:checked"). Length;if (len==0) {Alert ("Please select the national team!") ");return false;}else if (lenAlert ("Please select two national teams!") ");return false;}else if (len>2) {Alert ("Only choose two national teams!") ");return false;}else{return true;} 2. Traverse the selected natio
Requirements: There is an array: (Beijing cuisine, Cantonese cuisine), the checkbox is as follows:Now want to iterate through this array so that the values contained in the array are checked in the checkboxCode:var flavors = new Array ([Beijing cuisine, Cantonese cuisine]);$.each (flavors,function(i,item) {$ ("Input[name= ' Checkboxflavor '][value=" +item+ "]"). attr ("Checked", "checked");});Experience: th
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.