开发者

How to copy the following text from input box?

开发者 https://www.devze.com 2023-02-09 13:22 出处:网络
I\'ve got the following input box... <input type=\"text\" id=\"sharees\" class=\"form_field_as\">

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/

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号