javascript - Duplicate text from another form in real time -
okay probbaly question common, , many aks question , answer this. have (kinda) have problem. work if text vendor, text cgame follow text on vendor (keyup on real time), , can change on cgname (not affect text vendor). problem, when cgname empty or erase text wanna instaly text cgname text vendor mean duplicat text vendor cgname if text cgname erase or empty. how did that? code on jquery
var cgname = $("#cgname"); $("#vendor").keyup(function() { cgname.val( this.value ); });
i'm really2 sorry if u dont understand me said, english really2 worst.
update : many people miss understanding questio. i'm gonna cleary. 1. need duplictae text vendor text cgname 2. if text cganme erease or empty, go point 1.
based on ahjeebon's answer think looking :
$("#vendor").keyup(function() { $("#cgname").val( $(this).val()); }); $("#cgname").keyup(function() { var val = $(this).val(); if(!val || val.length === 0 ) $(this).val($('#vendor').val()); });
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> cg name <input id='cgname' type='text'> vendor <input id='vendor' type='text'>
Comments
Post a Comment