您的位置:首页 > Web前端 > JQuery

jQuery实现鼠标单击网页文字后在文本框显示的方法

2015-05-06 09:21 1026 查看

本文实例讲述了jQuery实现鼠标单击网页文字后在文本框显示的方法。分享给大家供大家参考。具体实现方法如下:

<!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>
<script src="js/jquery.min.js" type="text/javascript"></script>
</head>
<body>
<ul>
<li>张三</li>
<li>李四</li>
<li>王五</li>
<li>赵六</li>
</ul>
<table width="200" border="1" cellspacing="0" cellpadding="0">
<tr>
<td>选择</td>
<td>姓名</td>
</tr>
<tr>
<td><input type="checkbox" name="checkbox" value="1" /></td>
<td><input type="text" name="username" value="" /></td>
</tr>
<tr>
<td><input type="checkbox" name="checkbox" value="1" /></td>
<td><input type="text" name="username" value="" /></td>
</tr>
<tr>
<td><input type="checkbox" name="checkbox" value="1" /></td>
<td><input type="text" name="username" value="" /></td>
</tr>
</table>
<script>
$("ul li").click(function(){
var text = $(this).text();
$("input").val("");
$("input:checked").parents("td").siblings("td").children("input").val(text);
})
</script>
</body>
</html>

希望本文所述对大家的jQuery程序设计有所帮助。

您可能感兴趣的文章:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  jQuery 鼠标 文字