how to update two input boxes in jquery

2019-05-09 13:05发布

i create two input text fields , one for title and another for permanent link

i need to update the second filed automatically when user is typing the tilte

how can i do such a thing in jquery /php

somehow im looking for a way to simulate wordpress creation of permanent link in post section

3条回答
放荡不羁爱自由
2楼-- · 2019-05-09 13:32

Write a function to read from the current input, munge it however you like, and insert it into the other input.

Then bind that function to the keypress and change events.

查看更多
淡お忘
3楼-- · 2019-05-09 13:34
$('#first_input_id').bind('keydown', function(e){
     var inputmirror = $('#second_input_id');
     inputmirror.val(inputmirror.val() + String.fromCharCode(e.which));
});

Something similar to this should do it.

查看更多
混吃等死
4楼-- · 2019-05-09 13:45

You can intercept keyup event on the first input text, and then update the output of the second input:

    $('#titleInput').keypress(function(e) { alert ('typed' + String.fromCharCode(e.keyCode))//update your 2nd input text... 
}
查看更多
登录 后发表回答