target input by type and name (selector)

后端 未结 3 1432
野性不改
野性不改 2020-12-12 12:43

I need to change some checkbox inputs to hidden inputs for some but not all inputs on a page.



        
3条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-12 13:27

    You want a multiple attribute selector

    $("input[type='checkbox'][name='ProductCode']").each(function(){ ...
    

    or

    $("input:checkbox[name='ProductCode']").each(function(){ ...
    

    It would be better to use a CSS class to identify those that you want to select however as a lot of the modern browsers implement the document.getElementsByClassName method which will be used to select elements and be much faster than selecting by the name attribute

提交回复
热议问题