admin管理员组

文章数量:1356104

Get the input text field value on tool-tip.for me I am using text-box with autoplete..when ever i selected in autoplete it will show in text-box. when i hover it i want tool-tip the value in text-box..how to get that one can anyone can help me

<input type="text" value="something" class="curate">

Get the input text field value on tool-tip.for me I am using text-box with autoplete..when ever i selected in autoplete it will show in text-box. when i hover it i want tool-tip the value in text-box..how to get that one can anyone can help me

<input type="text" value="something" class="curate">

Share Improve this question asked Mar 3, 2017 at 9:47 Ravi KumarRavi Kumar 1191 silver badge11 bronze badges 3
  • Can you please show more code? you are being very evasive which doesn't help. Basically what you want is when you change ($('input.curate').change()) you want it to change something in tooltip too. – Luis Lopes Commented Mar 3, 2017 at 9:49
  • 2 Is the tooltip the native tooltip, provided via the title attribute, or is it provided by a plugin that you're using? – David Thomas Commented Mar 3, 2017 at 9:50
  • Actually i am not using drop-down..its a auto-plete.change() function it will work – Ravi Kumar Commented Mar 3, 2017 at 9:53
Add a ment  | 

5 Answers 5

Reset to default 4

Use the title attribute and pass the value of the input into the it on the keyup event.

$(document).ready(function(){
  $('#testInput').keyup(function(){
    $(this).attr('title',$(this).val())
  })
})
<script src="https://ajax.googleapis./ajax/libs/jquery/2.1.1/jquery.min.js"></script>
Type Something
<input type="text" title="" value="" id="testInput">

The first, you set the title is the value, and do the same when you change the value of textbox

function updateTitle(me)
{
me.title=me.value;
}
<input type="text" title="something" value="something" id="one" class="curate" onchange="updateTitle(this)">

I'd suggest:

$('input.curate').on('change', function (){
  this.title = this.value;
});
<input type="text" id="one" value="something"  class="curate">
<script>
var x=document.getElementById("one");
x.title=x.value;
</script>

You can using on hover to all inputs in you html like that :

$('input[type="text"],input[type="number"],input[type="date"]').hover(function() {
    $(this).attr('title', $(this).val()); });

本文标签: javascriptget the input text field value on tooltipStack Overflow