简体   繁体   English

使用Jquery将H3文本更改为输入val

[英]Change H3 text to input val with Jquery

I have hopefully a very straight forward question. 我希望这是一个非常直截了当的问题。 I have an H3 tag with some text in it. 我有一个带有一些文本的H3标签。 I need to have that text show up as the text value inputted in a text field, How can I make the H3 text the same as the text field with Jquery? 我需要将该文本显示为文本字段中输入的文本值,如何使用Jquery使H3文本与文本字段相同?

Here is the ID of the H3, detectiveFill_1 here is the ID of the input loc_else_text 这是H3的ID,detectiveFill_1这里是输入loc_else_text的ID

Thanks in advanced! 提前致谢!

This will update the h3 element on input focus lost 这将更新输入焦点丢失时的h3元素

$('#loc_else_text').change(function(){
    $('#detectiveFill_1').text(this.value);
});

This will update instantly on key pressed 这将在按下的键上立即更新

$('#loc_else_text').keyup(function(){
    $('#detectiveFill_1').text(this.value);
})

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM