jquery Operation Textarea,input,select,checkbox Method _jquery

Source: Internet
Author: User

Learn how to use jquery to write some small code today, try writing a textarea, the code is as follows:

<! DOCTYPE html>  

The effect chart is as follows:

Can be zoomed in and out, which is the advantage of the jquery effect.

One more input tag, code:

<! DOCTYPE html>  

The effect chart is as follows:

Add a focus and lose focus, default value, and then set a background color to get focus

The third one, wrote a Select, this thing generally in the QQ space and Taobao used more widely, so also more interested in the code as follows:

<! DOCTYPE html>  

The effect chart is as follows:

Move the option on the left to the right, and double-click to add more, haha, write code is very interesting,

Operation checkbox

Html

<a href= "javascript:;" id= "All" > All options </a><br>
 <a href= "javascript:;" id= "Delall" > Deselect </a><br>
 <a href= "javascript:;" id= "Antiall" > Reverse selection </a>   
 <p><input type= " CheckBox "Name=" CheckBox1 ">a
 <input type=" checkbox "Name=" CheckBox1 "> B
 <input type=" checkbox " Name= "CheckBox1" >C</p>
 <p><input type= "checkbox" Name= "CheckBox1" >d <input "type="
 CheckBox "Name=" CheckBox1 ">e
 <input type=" checkbox "Name=" CheckBox1 ">F</p>

jquery section

Select All
 $ ("#all"). Click (function () { 
 $ (' input[name= ' CheckBox1 ']). each (function () {
  $ (this). attr (" Checked ", true);
 }); 
 

Ordinary Javascirpt part:

function Checkall () {for
 (i=0;i<newtask.length;i++) {
 e=newtask.elements[i];
 if (e.type== ' checkbox ') {
  if (e.checked=false) {
  e.checked=true
  } else{
  e.checked=true
  }}
 } 

 

Deselect code:

jquery section:

Deselect
 $ ("#delAll"). Click (function () { 
 $ ("Input[name= ' CheckBox1 ')"). each (function () {
  $ (this). attr ("Checked", false);
 }); 
 

Common JavaScript section:

function Delall () {for
 (i=0;i<newtask.length;i++) {
 e=newtask.elements[i];
 if (e.type== ' checkbox ') {
  if (e.checked=true) {
  e.checked=false
  }
  else{
  e.checked=false
  }}
 }

Reverse Select Code:

jquery section:

Reverse Select
 $ ("#antiAll"). Click (function () {
 $ ("Input[name= ' CheckBox1 ')"). each (function () {
  $ (this). attr ( "Checked",!this.checked);       
   

Common JavaScript section:

function Antiall () {for
 (i=0;i<newtask.length;i++) {
 e=newtask.elements[i];
 if (e.type== ' checkbox ') {e.checked=!e.checked}}}

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.