Check a radio button with javascript

前端 未结 6 1660
一个人的身影
一个人的身影 2020-11-27 04:22

For some reason, I can\'t seem to figure this out.

I have some radio buttons in my html which toggles categories:



        
6条回答
  •  一向
    一向 (楼主)
    2020-11-27 04:32

    Easiest way would probably be with jQuery, as follows:

    $(document).ready(function(){
      $("#_1234").attr("checked","checked");
    })
    

    This adds a new attribute "checked" (which in HTML does not need a value). Just remember to include the jQuery library:

    
    

提交回复
热议问题