我有一个表单输入,由两个单选按钮组成,一个名称,如下所示:
<label for="thumb">[thumb]</label>
<input type="radio" name="type" value="thumb" checked />
<label for="img">[img]</label><input type="radio" name="type" value="img" />
Run Code Online (Sandbox Code Playgroud)
在jQuery函数中,我引用了哪一个被检查:
type=$('input[name="type"]').is(':checked').val();
Run Code Online (Sandbox Code Playgroud)
出于某种原因,即使我更改了页面上的复选框,如果总是返回前者.
以下是完整代码,用于消除:
<html>
<head>
<title>Thumb/img BBCode generator</title>
<script src='https://ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js'></script>
<meta http-equiv="Content-Style-Type" content="text/css" />
<link href="style.css" rel="stylesheet" type="text/css" />
<noscript>Please enable Javascript or use the <a href='index2.php'>old generator</a></noscript>
</head>
<body>
<h2>Thumb/img BBCode generator for Facepunch</h2>
<div id="content">
<form id="f" action="generate2.php" method="POST">
<label for="thumb">[thumb]</label>
<input type="radio" name="type" value="thumb" checked />
<label for="img">[img]</label><input type="radio" name="type" value="img" /><br />
<textarea rows="30" cols="40" name="text">Insert image links on seperate …Run Code Online (Sandbox Code Playgroud)