How can I select an element by name with jQuery?

前端 未结 14 2878
迷失自我
迷失自我 2020-11-22 05:13

Have a table column I\'m trying to expand and hide:

jQuery seems to hide the td elements when I select it by class but not by element\'s name.

<
14条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-11-22 05:55

    If you have something like:

    
    
    

    You can read all like this:

    jQuery("input[name='mycheckbox']").each(function() {
        console.log( this.value + ":" + this.checked );
    });
    

    The snippet:

    jQuery("input[name='mycheckbox']").each(function() {
      console.log( this.value + ":" + this.checked );
    });
    
    
    

提交回复
热议问题