javascript - Why is jQuery deleting last character of text? -


i have following jquery working in confluence page user input , auto-suggested links, , post them both forms in external page. user input coming out last character truncated. no matter length, lops off last letter.

for example if user types foobar post sends fooba. if user types foobar foobar foobar, turns foobar foobar fooba , on.

the code matters following:

$( document ).ready(function() {   $('form.aui').on('keypress', showhead);     function showhead() {      $('.suggesthead').delay(500).fadein(300);      $('.alertreq, .asterisk').css('visibility', 'hidden');  var dropdowntext = ($( "div.searchcontainer2  a.content-type-page span" ).text());      $('#capture').val( dropdowntext );      var inputvalue = $("#input2").val( );      $('#describe' ).val( inputvalue );     };       }); 

it's #describe value that's problem.

there's built-in confluence field gave id of "#input2", , when user types it, jquery above assigns user input variable called inputvalue, assigns variable hidden form field created id of "#describe". (this can use post on form, , other reasons).

if set alert see what's in #describe, this:

//alert function test selectors   $(document).on('click','.searchheading2',function(){      alert ($("#describe").val()); }); 

the alert contains user typed #input2 last letter deleted. ends in form on page i'm submitting to. know why this?

edit: sorry edited fix ajs.$ had left in 2 spots. that's confluence convention jquery, have replace $ ajs.$, , replace $( document ).ready(function() { ajs.toinit(function() {. wanted make regular jquery here wouldn't confusing. should right now.

answered a. wolff in comment:

use keyup event instead


Comments

Popular posts from this blog

node.js - How to mock a third-party api calls in the backend -

amazon web services - Installing MobileFirst 7.0 server on AWS -

Non Unique Username with ASP.Net Identity 2.0 -