简体   繁体   English

使用链接将文本添加到收件箱

[英]Use link to add text to inout box

I have a table of Codes and Prices. 我有一张代码和价格表。

The "codes" are set as a link - “代码”设置为链接-

CODENUMBER 编号

I have a form with the text box 我有一个带有文本框的表格

When the link in the table us added I want the code to be added to the input field. 当我们添加表中的链接时,我希望将代码添加到输入字段中。

This actually works great: 这实际上很好用:

<script type='text/javascript' src='http://code.jquery.com/jquery-1.7.1.js'></script>
<script type='text/javascript'>//<![CDATA[ 
$(window).load(function(){
$('a').click(function(){
$('#text_tag_input').val($('#text_tag_input').val()+$(this).html()+', ');  
$('#code').val($('#code').val()+$(this).html()+', ');
});

});//]]>  

</script>

But the site I am using a wordpress templated site that includes jquery 1.10.2 and the 1.7.1 is causing some of the "bits" of the site not to work so need the "onClick" action to work with 1.10.2 - or any other solution..... 但是我正在使用包含jquery 1.10.2和1.7.1的wordpress模板化网站的网站导致该网站的某些“位”不起作用,因此需要“ onClick”操作才能与1.10.2一起使用-或任何其他解决方案.....

Any help appreciated 任何帮助表示赞赏

Thanks 谢谢

Try this one use on event 在事件上尝试此一种用途

$('a').on('click',function(){
    $('#text_tag_input').val($('#text_tag_input').val()+$(this).html()+', ');  
    $('#code').val($('#code').val()+$(this).html()+', ');
});

There are no issues with the version of jQuery you are using. 您使用的jQuery版本没有问题。 Check out the code in the fiddle. 在小提琴中查看代码。 Try and change the version of jQuery to see the results. 尝试更改jQuery的版本以查看结果。 More code and examples of your problem might help... 更多代码和问题示例可能会有所帮助...

$('a').click(function(){
   $('#text_tag_input').val($('#text_tag_input').val() + $(this).html() + ', ');   
   $('#code').val($('#code').val()+$(this).html()+', ');
});

http://jsfiddle.net/c6Q88/1/ http://jsfiddle.net/c6Q88/1/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM