H3标签中的jQuery值替换为文本框中的值 [英] jQuery value in H3 Tag replace by value from Text Box

查看:109
本文介绍了H3标签中的jQuery值替换为文本框中的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个h3标签

<h3> <a href="#"> Initial Text</a></h3>

,我有一个TextBox. 在该文本框中键入某些"值

and i have a TextBox. When a Some values is typed in that TextBox

<input id="Medication" name="Medication" size="50" type="text" value="">

该定位链接(初始文本)中的值

The value in that anchor link (Initial Text)

应替换为文本框中的值.

Should be replaced with the Value in the TextBox.

我该怎么做? 有人可以帮我吗?

How can i do that? can any one help me with this?

谢谢

推荐答案

尝试:

$('#medication').blur(function(){
  var objVal = $(this).val();
  if(objVal != ''){
    $('h3 a').text(objVal);
  }
});

这将附加 blur()事件处理程序,以在文本框丢失时执行提供的功能重点.该函数将检查是否设置了该值,如果设置了该值,则它将更新您的<a>标记中的文本.

This will attach the blur() event handler to execute the provided function when the text box loses focus. The function will check if the value is set and if it is then it will update the text in your <a> tag.

这篇关于H3标签中的jQuery值替换为文本框中的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆