Francesco Curletti
Francesco Curletti

Reputation: 13

Change text into <span> with jquery comand

I need to change text into a span.

I'm looking for this because I have a drop-down menu, I use a jQuery selector option but this does not change the text, select only from the options.

I need to change "seleziona" with other text.

Upvotes: 0

Views: 82

Answers (2)

DinoMyte
DinoMyte

Reputation: 8868

The answer posted by Srebnywilkun is correct. This answer only provides a short notation.

$("#span1").on('change',function(){
    $("#span2").text('calculated value');
}).change(); // defining this at the end of the function would automatically trigger the change event after the event is registered.

Upvotes: 0

Srebnywilkun
Srebnywilkun

Reputation: 7

  1. You can do a change event
  2. Then trigger it

1.

$("#span1").on('change',function(){
 //Do calculation and change value of other span here
 $("#span2").text('calculated value');});

2.

$("#span1").text('test').trigger('change'); 

Upvotes: 1

Related Questions