Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery value in H3 Tag replace by value from Text Box

i have a h3 tag

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

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?

Thanks

like image 857
HaBo Avatar asked Dec 05 '25 10:12

HaBo


1 Answers

Try:

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

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.

like image 83
Robert Avatar answered Dec 08 '25 01:12

Robert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!