javascript - Why it won't pass the string to input field but it shows in HTML? -


when loads, can see key this
your key: shf8tg382kds
however, key won't appear in input field.
why? , how can solve this?

javascript part

<script>     window.onload = function(){         $(".chat#key").val($('#peer-id').text()).focus()     } </script> 

html part

<p>your key : <span id="peer-id"></span> </p>  <input class="chat" id="key" name="messages[body]" placeholder="type key here!" type="text" /> 

update

if change this, shows abc in input field.

$(".chat#key").val('abc').focus() 


Comments

Popular posts from this blog

database - VFP Grid + SQL server 2008 - grid not showing correctly -

jquery - Set jPicker field to empty value -

.htaccess - htaccess convert request to clean url and add slash at the end of the url -