如何将 p 标签中的文本回调到输入文本字段?
How to call back text from p tag to the input text feild?
有两个相同的 id,我只想添加一些 jquery 来完成以下工作,每当 p
标签文本更改时,输入值会根据 p 标签的文本自动更改.
$(document).ready(function(){
$('#walletconnect').hover(function(){
//MOUSE ENTERS
$('#walletconnect').css('display', 'block');
var x = $('#walletconnect').text();
$('#walletaddressinput').text(x);
//Here you can use $('#tooltip').text(x); to make text display in the tooltip
},function(){
//MOUSE LEAVES
$('#walletaddressinput').css('display', 'none');
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="App">
<div><button class="btn btn-primary my-4" type="button">WalletConnect</button></div>
<p id="walletconnect">0x779d4E727232*********BDBC03aE84C</p>
</div>
<input type="text" name="wallet_address" class="form-control" id="walletaddresssinput" maxlength="50" placeholder="Wallet address" title="" required="">
尝试一下,点击连接按钮
$(document).ready(function() {
var x = $('#walletconnect');
$('.btn').on('click', function() {
x.text("newtext");
});
$(document).on("DOMSubtreeModified", "#walletconnect", function() {
$('#walletaddresssinput').val(x.text());
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="App">
<div><button class="btn btn-primary my-4" type="button">WalletConnect</button></div>
<p id="walletconnect">0x779d4E727232*********BDBC03aE84C</p>
</div>
<input type="text" name="wallet_address" class="form-control" id="walletaddresssinput" maxlength="50" placeholder="Wallet address" title="" required="">
有两个相同的 id,我只想添加一些 jquery 来完成以下工作,每当 p
标签文本更改时,输入值会根据 p 标签的文本自动更改.
$(document).ready(function(){
$('#walletconnect').hover(function(){
//MOUSE ENTERS
$('#walletconnect').css('display', 'block');
var x = $('#walletconnect').text();
$('#walletaddressinput').text(x);
//Here you can use $('#tooltip').text(x); to make text display in the tooltip
},function(){
//MOUSE LEAVES
$('#walletaddressinput').css('display', 'none');
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="App">
<div><button class="btn btn-primary my-4" type="button">WalletConnect</button></div>
<p id="walletconnect">0x779d4E727232*********BDBC03aE84C</p>
</div>
<input type="text" name="wallet_address" class="form-control" id="walletaddresssinput" maxlength="50" placeholder="Wallet address" title="" required="">
尝试一下,点击连接按钮
$(document).ready(function() {
var x = $('#walletconnect');
$('.btn').on('click', function() {
x.text("newtext");
});
$(document).on("DOMSubtreeModified", "#walletconnect", function() {
$('#walletaddresssinput').val(x.text());
});
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="App">
<div><button class="btn btn-primary my-4" type="button">WalletConnect</button></div>
<p id="walletconnect">0x779d4E727232*********BDBC03aE84C</p>
</div>
<input type="text" name="wallet_address" class="form-control" id="walletaddresssinput" maxlength="50" placeholder="Wallet address" title="" required="">