求助jquery获取父子元素的问题 jqueryjavascriptcheckbox 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 div class="username" 这个 div 显示或者隐藏是不? $(':checkbox').change(function(){$('div.username')[this.checked?'show':'hide']()}) 这个table不止一行,有很多行这样的,到我只想让选中的当前这行的样式显示或隐藏 这个table不止一行,有很多行这样的,到我只想让选中的当前这行的样式显示或隐藏$(':checkbox').change(function(){$(this).parents('tr').find('div.username')[this.checked?'show':'hide']()}) <script src=scripts/jquery-1.8.3.min.js></script><script>$(function() { $('.user_resource .username').hide(); $('.user_resource :checkbox').click(function() { if($(this).prop('checked')) $(this).parents('tr').find('.username').show(); else $(this).parents('tr').find('.username').hide(); });})</script><div class="user_resource"><table width="100%" > <tr height="90px"> <td width="7%" align="center"> <input type="checkbox"/> </td> <td width="30%" align="center">人力资源管理系统</td> <td width="19%" align="center"> <img src="images/13.png"> </td> <td width="44%" align="center"> <div class="username">用户名:<input type="text" name="appUserName" id="appUserName"/></div> </td> </tr> </table> </div> <!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=utf-8" /><title>无标题文档</title><style>.username{ border:#F00 1px solid; width:200px; height:300px;}</style></head><body><script src="jquery-1.9.0.js"></script><script>$(function(){ $(':checkbox').click(function(){ if($(this).prop('checked')){ $(this).parents('tr').find("div").addClass("username"); }else{ $(this).parents('tr').find("div").removeClass("username"); } });})</script><div class="user_resource"><table width="100%" > <tr height="90px"> <td width="7%" align="center"> <input type="checkbox"/> </td> <td width="30%" align="center">人力资源管理系统</td> <td width="19%" align="center"> <img src="images/13.png"> </td> <td width="44%" align="center"> <div>用户名:<input type="text" name="appUserName" id="appUserName"/></div> </td> </tr></table> </div></body></html> $(function() { $('.user_resource .username').hide(); $('.user_resource :checkbox').click(function() { if($(this).prop('checked')) $(this).parents('tr').find('.username').show(); else { $(this).parents('tr').find('.username').hide(); $(this).parents('tr').find('#appUserName').val(''); } });}) Json 数据解析问题求解 求SWFObject高手解答,后台返回的值怎么嵌入到.swf中 ext中如何给form添加背景图片?急!! 一个大公司很有难度的面试题 【高手接分】问一个dtree的问题,100分放送 为什么.click()这样的javascript语句在firefox里面无效? 请教FLASH问题 关于csdn所用到的一些javascript函数的问题 有关frame页面的问题 小练习 Extjs4.2 使用 RowEditing 编辑,怎么实现当一个文本框值改变时,另一个也改变 自学《javascript高级程序设计》持续更新,请大家监督
$(':checkbox').change(function(){$(this).parents('tr').find('div.username')[this.checked?'show':'hide']()})
<script>
$(function() {
$('.user_resource .username').hide();
$('.user_resource :checkbox').click(function() {
if($(this).prop('checked')) $(this).parents('tr').find('.username').show();
else $(this).parents('tr').find('.username').hide();
});
})
</script>
<div class="user_resource">
<table width="100%" >
<tr height="90px">
<td width="7%" align="center">
<input type="checkbox"/>
</td>
<td width="30%" align="center">人力资源管理系统</td>
<td width="19%" align="center">
<img src="images/13.png">
</td>
<td width="44%" align="center">
<div class="username">用户名:<input type="text" name="appUserName" id="appUserName"/></div>
</td>
</tr>
</table>
</div>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
.username{ border:#F00 1px solid; width:200px; height:300px;}
</style>
</head>
<body>
<script src="jquery-1.9.0.js"></script>
<script>
$(function(){
$(':checkbox').click(function(){
if($(this).prop('checked')){
$(this).parents('tr').find("div").addClass("username");
}else{
$(this).parents('tr').find("div").removeClass("username");
}
});
})
</script>
<div class="user_resource">
<table width="100%" >
<tr height="90px">
<td width="7%" align="center">
<input type="checkbox"/>
</td>
<td width="30%" align="center">人力资源管理系统</td>
<td width="19%" align="center">
<img src="images/13.png">
</td>
<td width="44%" align="center">
<div>用户名:<input type="text" name="appUserName" id="appUserName"/></div>
</td>
</tr>
</table>
</div>
</body>
</html>
$('.user_resource .username').hide();
$('.user_resource :checkbox').click(function() {
if($(this).prop('checked')) $(this).parents('tr').find('.username').show();
else {
$(this).parents('tr').find('.username').hide();
$(this).parents('tr').find('#appUserName').val('');
}
});
})