Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
532 views
in Technique[技术] by (71.8m points)

jquery - change event of html hidden field

I want to check the change of html hidden field using jquery and i tried for this but the change event did not worked.

Somebody has and idea how to handle this?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

The change event doesn't fire when the value is programmatically changed, if it did it would cause infinite loops in many situations.

If you need the event to fire, then trigger it when changing the value yourself using .change(), like this:

$("#hiddenId").val("new value").change();

.change() is a shortcut for .trigger("change") or, if you don't want that change event to bubble for some reason, then use .triggerHandler("change").


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...