开发者

append string to textbox contents?

pretty simple, I have buttons but i want to add their value to a textbox when they are clicked, ho开发者_高级运维w would i go about doing this in jQuery? They are all numbers and their cant be more than 10 in the textbox.


pretty easy task with jQuerys .val()help method:

$('button').click(function(event) {
    $('input:text').val(function(index, val) {
        return val + event.target.value;
    });
});

Demo: http://www.jsfiddle.net/QFm7K/


or

$('button').click(function() {
    $('textarea')[0].value += $(this).val();
});


use jquery .val to set the text box value , it should do it

http://api.jquery.com/val/

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜