开发者

text assign to textbox onclick hyperlink

开发者 https://www.devze.com 2023-04-01 01:40 出处:网络
I have problem on j开发者_Python百科query onclick. when onclick happen on a link text box value should fill with the some hard coded text.

I have problem on j开发者_Python百科query onclick. when onclick happen on a link text box value should fill with the some hard coded text.

ex

  $('#linkBase').click(function() {

         $('#txtFormula').val("txnword");

    });

problem is I want to repeat the "txtword" on the text box when I click on the link as "txtwordtxtwordtxtwordtxtwordtxtword" but currently I'm getting only once when click the link.


Try this:

 $('#linkBase').click(function() {
               $('#txtFormula').val($('#txtFormula').val() + "txnword");                 
});


var formula = $('#txtFormula');
formula.val(formula.val() + "txnword");


For those that doesn't use jQuery for simple things like this:

document.querySelector('#linkBase').onclick = function()
{
    document.querySelector('#txtFormula').value += "txnword";
};
0

精彩评论

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