简体   繁体   中英

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.....

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. Check out the code in the fiddle. Try and change the version of jQuery to see the results. 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/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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