current position:Home>The jQuery radio value is unchecked and assigned

The jQuery radio value is unchecked and assigned

2021-08-22 05:30:19 mb611f1a641bd18

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title> Untitled Document </title>
<script type="text/javascript" src="jquery-1.11.1.min.js">
    
</script>
<script>
    $(function() {
        $("#studentBtn").click(function() {
            //var student = $("#student").val();// Whether you choose or not , Take the first one 
            //var student = $("#student:checked").val();// Take the middle item 
            //$("#student:checked").attr("checked",false);// Uncheck the item 
            //$("#student:eq(3)").attr("checked",true);// Specify the selected item ( Invalid )
            //$("#student[value=2]").attr("checked",true);// Specify the selected item (IE8 It works , Google is not available ,qq(IE10 kernel ) Unavailable , Firefox is invalid )
            //$("#student[type=radio]:eq(2)").attr("checked",true);// Specifies the selected item 
            //$("#student[value=2]").attr("checked",true);// Select the item with the specified value ( Invalid )
            //$("input[id=student][value=2]").attr("checked",true);// Select the item with the specified value 
            //var studentNo = $("#studentNo").val();
            //$("#student:checked").attr("checked",false);
            // Select the item with the specified value (1、IE The available (IE8 kernel ) 2、 Available under Google  3、QQ(IE10 kernel ) Only the first execution is successful , The second time is invalid  4、 No matter how many times it doesn't work under Firefox )
            //$("input[type=radio][name=student][value='"+$("#studentNo").val()+"']").attr("checked",true);
            //alert(student);
        });
    })
</script>
</head>

<body>
    <input name="student" id="student" type="radio" value="0" /> Zhang SA 
    <input name="student" id="student" type="radio" checked="checked" value="1" /> Liz 
    <input name="student" id="student" type="radio" value="2" /> Wang Wu 
    <input name="student" id="student" type="radio" value="3" /> Zhao Li   Enter the student id :
    <input type="text" name="studentNo" id="studentNo" value="0" />
    <input type="button" name="studentBtn" id="studentBtn" onclick="chooseStudent()" value=" determine " />
</body>
</html>
   
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.

 

copyright notice
author[mb611f1a641bd18],Please bring the original link to reprint, thank you.
https://en.qdmana.com/2021/08/20210822052957941v.html

Random recommended