-5
$("#pass").val("").trigger("change");
$("#pass_con").val("").trigger("change");

What s the use of using trigger statement here

Mohammad
  • 21,175
  • 15
  • 55
  • 84
Dhamodharaan M
  • 123
  • 1
  • 1
  • 9

2 Answers2

0

On change event occurs when user enters values manually, i.e. events initiated by user and not the JS code. Setting the value using .val() do not trigger change event.

Thus,.trigger("change"); or .change(); needs to be used for triggering change event attached to it.

Milind Anantwar
  • 81,290
  • 25
  • 94
  • 125
0

May be there are change listeners registered on #pass, #pass_con elements.

Changing the value of these nodes programatically will not trigger a change event.

Manually triggering the change event for the listeners to be notified.

Vinay K
  • 5,562
  • 1
  • 18
  • 27