There are two identical ids and i just want to add some jquery which will do the following job, whenever p
tag text changes then input value automatically changes itself according to text of p tag.
JavaScript
x
14
14
1
$(document).ready(function(){
2
$('#walletconnect').hover(function(){
3
//MOUSE ENTERS
4
$('#walletconnect').css('display', 'block');
5
var x = $('#walletconnect').text();
6
$('#walletaddressinput').text(x);
7
//Here you can use $('#tooltip').text(x); to make text display in the tooltip
8
9
},function(){
10
//MOUSE LEAVES
11
$('#walletaddressinput').css('display', 'none');
12
13
});
14
});
JavaScript
1
6
1
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
2
<div class="App">
3
<div><button class="btn btn-primary my-4" type="button">WalletConnect</button></div>
4
<p id="walletconnect">0x779d4E727232*********BDBC03aE84C</p>
5
</div>
6
<input type="text" name="wallet_address" class="form-control" id="walletaddresssinput" maxlength="50" placeholder="Wallet address" title="" required="">
Advertisement
Answer
give it a try, clicking on the connect button
JavaScript
1
9
1
$(document).ready(function() {
2
var x = $('#walletconnect');
3
$('.btn').on('click', function() {
4
x.text("newtext");
5
});
6
$(document).on("DOMSubtreeModified", "#walletconnect", function() {
7
$('#walletaddresssinput').val(x.text());
8
});
9
});
JavaScript
1
6
1
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
2
<div class="App">
3
<div><button class="btn btn-primary my-4" type="button">WalletConnect</button></div>
4
<p id="walletconnect">0x779d4E727232*********BDBC03aE84C</p>
5
</div>
6
<input type="text" name="wallet_address" class="form-control" id="walletaddresssinput" maxlength="50" placeholder="Wallet address" title="" required="">