Cov txheej txheem:

Yuav ua li cas koj nrhiav tau checkbox yog check los yog tsis nyob rau hauv jQuery?
Yuav ua li cas koj nrhiav tau checkbox yog check los yog tsis nyob rau hauv jQuery?

Video: Yuav ua li cas koj nrhiav tau checkbox yog check los yog tsis nyob rau hauv jQuery?

Video: Yuav ua li cas koj nrhiav tau checkbox yog check los yog tsis nyob rau hauv jQuery?
Video: Why has Vitae not reopened globally yet | Vitae Green Sprouts 2024, Hlis ntuj nqeg
Anonim

Siv lub jQuery: checked Selector

  1. $('input[type=" checkbox "]'). nyem(function(){
  2. if($(this). is(": kuaj ")){
  3. ceeb toom(" Checkbox raug kuaj .");
  4. }
  5. yog tias ($(qhov no). is(": tsis yog (: kuaj )")){
  6. ceeb toom(" Checkbox yog tsis tau txheeb xyuas .");
  7. }

Hauv qhov no, yuav ua li cas checkbox check lossis tsis nyob hauv JavaScript?

Input Checkbox check Property

  1. Teem lub xeev checkbox: function check() { document.
  2. Tshawb xyuas seb lub checkbox puas raug kuaj lossis tsis: getElementById("myCheck"). kuaj;
  3. Siv lub checkbox los hloov cov ntawv hauv qhov chaw nkag mus rau cov ntawv loj: getElementById("fname"). value = document.
  4. Ob peb checkboxes nyob rau hauv ib daim ntawv: var kasfes = document. forms[0];

Ib sab saum toj no, koj ua li cas checkbox yog kuaj los yog tsis nyob rau hauv Angularjs? Tsuas yog txhais cov lus qhia ng-qauv hauv qhov checkbox thiab nrhiav checkbox check lossis tsis kos tus qauv xa rov qab tus nqi (TRUE lossis FALSE). Yog nws muaj TRUE txhais tau tias checkbox yog ua kuaj.

Tsis tas li ntawd, koj yuav ua li cas xyuas lub checkbox yog kuaj los yog tsis nyob rau hauv selenium?

Nyob rau hauv thiaj li yuav kuaj yog a checkbox yog check los yog unchecked , peb tuaj yeem siv isSelected() txoj hauv kev checkbox keeb. Txoj kev isSelected() rov qab tus nqi boolean ntawm qhov tseeb yog tias checkbox raug kuaj cuav lwm yam.

Koj tuaj yeem tshawb xyuas seb lub checkbox puas tau kuaj lossis tsis?

Piv txwv

  1. $('input[type="checkbox"]'). nyem(function(){
  2. if($(this).prop("checked") == true){
  3. ceeb toom("Checkbox yog check.");
  4. }
  5. else if($(this). prop("checked") == cuav){
  6. ceeb toom("Checkbox tsis tau txheeb xyuas.");
  7. }

Pom zoo: