0

How to trigger on text change inside a ?

I have input field using a draggable range slider, the value from the slider gets printed into this .

I want to trigger a function when the value changes inside the

<strong><span class="description"></span><i>verdi i kg:</i></strong>
<input type="text" style="border: 0px !important">

How can this be achieved?

sdfgg45
  • 1,232
  • 4
  • 22
  • 42
  • instead of listening for text change inside `strong` listen for value change on range slider. – SachinGutte Apr 14 '16 at 10:42
  • There is no event to handle text change in `i` element. Refer to [this](http://stackoverflow.com/questions/15657686/jquery-event-detect-changes-to-the-html-text-of-a-div), may be useful to you. – Bhushan Kawadkar Apr 14 '16 at 10:44

2 Answers2

1

You need to handle the mousemove event:

    $(':input').mousemove(function(){
        $('span').html($(':input').val());
    });

Check jsfiddle

kbysiec
  • 578
  • 1
  • 4
  • 21
0

Listen the slider change event,

$("#sliderId").on("input change mousemove",function(){
$("input").text($(this).val());
});

$("input").on("change",function(){
//do what you need
});
Arumuga Raja
  • 184
  • 13
  • i need to trigger on the value inside the input when its changed, if posible. – sdfgg45 Apr 14 '16 at 10:49
  • You want to trigger a event if the slider value changed right?.. `change` will trigger while you after you set the value in the slider and `input` will trigger while you dragging the slider thumb. What you need now other than this – Arumuga Raja Apr 14 '16 at 10:53
  • it updates when i drop, but not while dragging, i need to show updated values while dragging the slider as well. – sdfgg45 Apr 14 '16 at 10:55
  • Refer http://stackoverflow.com/questions/18544890/onchange-event-on-input-type-range-is-not-triggering-in-firefox-while-dragging it may help you – Arumuga Raja Apr 14 '16 at 11:00