<a title="qwe">标签里 加onclick ,点击则在一个input里显示出qwe来,怎么搞? <a title="qwe">标签里 加onclick ,点击则在一个input里显示出qwe来,怎么搞? 有好多<a> 点那个显示那个的title值。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 给input加个id<a title="qwe" onclick="document.getElementById('ipt').value=this.title" /> 如果你有很多这种a标签的话,那么将onclick的代码封装一下<script> function ck(obj){ document.getElementById('ipt').value=obj.title; }</script><a title="qwe" onclick="ck(this)" /> <body><a title="asdf" href="#">asdf</a><a title="qwer" href="#">qwer</a><a title="zxcv" href="#">zxcv</a><input id="txtValue" type="text" /></body><script> $('a').click(function() { $("#txtValue").val($(this).attr("title")); })</script> <!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></head><body><a href="#" title="11">11</a><input type="text" /><br /><a href="#" title="22">22</a><input type="text" /><br /><a href="#" title="33">33</a><input type="text" /><br /><script> var as = document.getElementsByTagName('a'); for(var i = 0,a; a = as[i++];){ if(a.title){ a.onclick = function(){ this.nextSibling.value = this.title; return false; }; } }</script></body></html>给你写了个例子~·如果要用的话,看好我的结构~·要不你还得改JS代码~` 我现在只需要一个input就行了, 然后点那个<a>,这个input就显示谁的,你的代码太高级了。 <html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title></title> <script src="../js/jquery-vsdoc.js" type="text/javascript"></script> <script src="../js/jquery.js" type="text/javascript"></script></head><body><a title="asdf" href="#">asdf</a><a title="qwer" href="#">qwer</a><a title="zxcv" href="#">zxcv</a><input id="txtValue" type="text" /></body><script> $('a').click(function() { $("#txtValue").val($(this).attr("title")); })</script></html>之前要引用jquery ok了,结贴前想问一句 <script src="../js/jquery-vsdoc.js" type="text/javascript"></script> <script src="../js/jquery.js" type="text/javascript"></script> /jquery-vsdoc.js 这个是干什么的? 我只引用了jquery.js 就成功了。 他俩一样吗 <script src="../js/jquery-vsdoc.js" type="text/javascript"></script> <script src="../js/jquery.js" type="text/javascript"></script> 上面那个是我vs2008 jquery提示的 你引用下面那个就OK了... 用js实现菜单浮动显示 jQuery 如何自定义一个函数,并且同时带回调函数的 JavaScript对javaweb开发重要吗 arguments是js的内置对象。 急!!!!JS中定义三维变量问题 不提交表单,怎样读取TXET中的值? 请孟老大出面看一下,JS控制CSS的问题,有的能改变,有的不能改,也请精通JS的朋友知道这个问题的请帮忙,不胜感激. 急啊,请问如何用cookie来控制弹出窗口,用JS写的!!!! 谢谢帮忙 window.location.reload()是什么意思?怎么用??? js IE7以上自动网页全屏 请问下我这个在FF和chrome为什么弹不出来选中的值
<a title="qwe" onclick="document.getElementById('ipt').value=this.title" />
<script>
function ck(obj){
document.getElementById('ipt').value=obj.title;
}
</script>
<a title="qwe" onclick="ck(this)" />
<body>
<a title="asdf" href="#">asdf</a><a title="qwer" href="#">qwer</a><a title="zxcv" href="#">zxcv</a><input id="txtValue" type="text" />
</body>
<script>
$('a').click(function() {
$("#txtValue").val($(this).attr("title"));
})
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head><body>
<a href="#" title="11">11</a><input type="text" /><br />
<a href="#" title="22">22</a><input type="text" /><br />
<a href="#" title="33">33</a><input type="text" /><br />
<script>
var as = document.getElementsByTagName('a');
for(var i = 0,a; a = as[i++];){
if(a.title){
a.onclick = function(){
this.nextSibling.value = this.title;
return false;
};
}
}
</script>
</body>
</html>
给你写了个例子~·如果要用的话,看好我的结构~·要不你还得改JS代码~`
<head runat="server">
<title></title> <script src="../js/jquery-vsdoc.js" type="text/javascript"></script> <script src="../js/jquery.js" type="text/javascript"></script></head>
<body>
<a title="asdf" href="#">asdf</a><a title="qwer" href="#">qwer</a><a title="zxcv" href="#">zxcv</a><input id="txtValue" type="text" />
</body>
<script>
$('a').click(function() {
$("#txtValue").val($(this).attr("title"));
})
</script>
</html>
之前要引用jquery
<script src="../js/jquery-vsdoc.js" type="text/javascript"></script> <script src="../js/jquery.js" type="text/javascript"></script> /jquery-vsdoc.js 这个是干什么的? 我只引用了jquery.js 就成功了。 他俩一样吗
<script src="../js/jquery-vsdoc.js" type="text/javascript"></script> <script src="../js/jquery.js" type="text/javascript"></script>
上面那个是我vs2008 jquery提示的 你引用下面那个就OK了...