突然发现这简单的问题还真不懂 <label id="Label1"> <input type="checkbox"/> </label>要求是获得用户选中这个checkbox之后的html,则预期alert出来的结果是“<input type="checkbox" checked="checked"/>”但是一般的jquery或者js这样写,得不到预期的结果alert($('#Label1')[0].innerHTML);/////alert($('#Label1').html());动态 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 厄。。要检测checkbox是否选中,用jquery的prop就可以但是我要的是获取Label1里面所有的标签最新的标签。。厄。。我表达有点问题。。Label1里面有很多标签内容,这个只是一个例子。 <!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" /><script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script><title>无标题文档</title></head><body><label id="Label1"> <input type="checkbox"/>check item</label><script type="text/javascript">jQuery(function($){ $(":checkbox").click(function(){ if($(this).is(':checked')){ $(this).attr('checked','checked'); }else{ $(this).removeAttr('checked'); } alert($('#Label1').html()); }); });</script></body></html> jsp页面 如下的图标如何显示 插入新元素不成功 渐显效果 求助 在dom 插入 一个div prototype.js中的this 【高分求正则】匹配中文或中文全角标点 这个效果用层怎么做 swfupload/extjs3,添加按钮没反应的问题 当横向图片多的时候,如何动态生成横向滚动条? 怎样让提示窗口不消失? 问一个JQuery UI里关于Dialog的样式问题 当鼠标在图片上使图片向左旋转45度 然后再向右旋转45度
但是我要的是获取Label1里面所有的标签最新的标签。。
厄。。我表达有点问题。。
Label1里面有很多标签内容,这个只是一个例子。
<!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" />
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
<title>无标题文档</title>
</head><body><label id="Label1">
<input type="checkbox"/>check item
</label>
<script type="text/javascript">
jQuery(function($){
$(":checkbox").click(function(){
if($(this).is(':checked')){
$(this).attr('checked','checked');
}else{
$(this).removeAttr('checked');
}
alert($('#Label1').html());
});
});
</script>
</body>
</html>