1. 전체 선택/전체 선택/반선택 버튼 기능 구현

3379 단어

1. 효과 프레젠테이션


원하는 언어를 선택하십시오.
Java JavaScript php Python 전체/전체 선택 안 함

2. 원본 전시

 <span style="color:#000000;">
          $().ready(</span><span style="color:#0000ff;">function</span><span style="color:#000000;">(){
              </span><span style="color:#008000;">//</span><span style="color:#008000;"> input checkbox name="items", attr checked </span>
              $("#checkItems").click(<span style="color:#0000ff;">function</span><span style="color:#000000;">(){
                  </span><span style="color:#0000ff;">if</span>($(<span style="color:#0000ff;">this</span>).attr("checked"<span style="color:#000000;">)){
                      $(</span>":checkbox[name='items']").attr("checked",<span style="color:#0000ff;">true</span><span style="color:#000000;">);
                  }</span><span style="color:#0000ff;">else</span><span style="color:#000000;">{
                      $(</span>":checkbox[name='items']").attr("checked",<span style="color:#0000ff;">false</span><span style="color:#000000;">);
                  }
              });
              </span><span style="color:#008000;">//</span><span style="color:#008000;"> input checkbox name="items", </span>
              $("#check_reversal").click(<span style="color:#0000ff;">function</span><span style="color:#000000;">(){
                  $(</span>":checkbox[name='items']").each(<span style="color:#0000ff;">function</span><span style="color:#000000;">(){
                      </span><span style="color:#0000ff;">if</span>($(<span style="color:#0000ff;">this</span>).attr("checked"<span style="color:#000000;">)){
                          $(</span><span style="color:#0000ff;">this</span>).attr("checked",<span style="color:#0000ff;">false</span><span style="color:#000000;">);
                      }</span><span style="color:#0000ff;">else</span><span style="color:#000000;">{
                          $(</span><span style="color:#0000ff;">this</span>).attr("checked",<span style="color:#0000ff;">true</span><span style="color:#000000;">)
                      }
                  });
              });
          });
  </span>
  
/
Java JavaScript php Python

3. 총결산

$(this): 。

 
다음으로 전송:https://www.cnblogs.com/lyajs/p/5974543.html

좋은 웹페이지 즐겨찾기