How to copy the following text from input box?
I've got the following input box...
<input type="text" id="sharees" class="form_field_as">
and I'm using the following to attempt to capture what is typed..
var txt2 = $('input[class="form_field_as"]').serialize();
However, that doesn't seem 开发者_运维技巧to be working. it's returning ""
. What am I doing wrong?
try
var txt2 = $('input.form_field_as').val();
or by id
var txt2 = $('#sharees').val();
Try
$(function(){
$('input.form_field_as').keyup(function(){
var txt2 = $('input.form_field_as').val();
$('p').text(txt2);
})
});
Your code is wrong. That type of writing is used for other attributes. For an id use #
and for a class use .
.
http://jsfiddle.net/borayeris/qGT4W/1/
精彩评论