Javascript 选中单选按钮时文本框不显示

Javascript 选中单选按钮时文本框不显示,javascript,jquery,jquery-plugins,Javascript,Jquery,Jquery Plugins,尝试选择使文本框出现的任何单选按钮,但实际上它不起作用:(.这里是jsp页面中的html <%@ page language="java" contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loos

尝试选择使文本框出现的任何单选按钮,但实际上它不起作用:(.这里是jsp页面中的html

<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<style type="text/css">
input[type=text]{
  display : none
}
</style>
<script type="text/javascript" language="text/html" src="../jscript/jquery-1.7.2.js"></script>
<script type="text/javascript" language="javascript" src="../jscript/jquery-1.4.2.min.js"></script>
<script type="text/javascript"> // I 'm using your 1st jquery whose usage is void of css
$('input[type=radio]').change(function() {
    $('input[type=text]').css('display','none');
     $(this).closest('tr').find('input[type=text]').css('display','block');
});
</script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Test </title>
</head>
<body>
<form action="">
<div align="left" style="color:#2D7EE7">
<table>
<tr>
<td>
<input type="radio" name="radio" value="college"></td> 
<td>College  </td>
<td><input type="text" name="clg"></td></tr>
<tr>
<td><input type="radio" name="radio" value="school"></td>
<td> School </td>
<td><input type="text" name="schl"></td>
</tr>
</table>
</div>
</form>
</body>
</html>

输入[类型=文本]{
显示:无
}
//我正在使用你的第一个jquery,它的用法是无效的css
$('input[type=radio]')。更改(函数(){
$('input[type=text]').css('display','none');
$(this).closest('tr').find('input[type=text]')).css('display','block');
});
试验
学院
学校
下面是jquery的一段代码:

<script type="text/javascript">
$('input[type=radio]').change(function() {
       $('input[type=text]').hide();
       $(this).parent().next().show();
    });
</script>

$('input[type=radio]')。更改(函数(){
$('input[type=text]')。隐藏();
$(this.parent().next().show();
});
和css:

<style type="text/css">
input[type=text]{
  display : none
}
</style>

输入[类型=文本]{
显示:无
}
但这仍然不起作用:(:),所以任何人都可以猜到我错在哪里。请随意评论。

将其改为:

            $('input[type=radio]').change(function() {
                $('input[type=text]').hide();
                 $(this).closest('tr').find('input[type=text]').show();
            });


首先尝试在页面中只包含一个JQuery脚本(删除JQuery-1.4.2.min.js)

$(':radio')
相当于
$('[type=radio]')


$('input[type=radio]')
我认为收音机必须在引号中
$('input[type=“radio”]”)
如果我错了,请更正我必须在代码中添加此css文本的位置?因为在JSFIDLE中它工作,但在我的页面中它不工作……猜猜为什么(我将更改我的代码以直接设置显示css。让我知道它是否有效&我必须添加的css在哪里?您可以在问题中使用您当前的css。)
        $(document).ready(function(){
            $('input[type=radio]').change(function() {
                $('input[type=text]').css('display','none');
                $(this).closest('tr').find('input[type=text]').css('display','block');
            });
        });
$(document).ready(function(){
    $(':radio').change(function() {
        // Hide all input:text in the table     
        $('input:text', $(this).closest("table")).hide(); 
        $(this).parent().nextAll().find('input:text').show();
    });
});