2

How to use Jquery if any field is being changed using javascript?

I have hidden field whose value is being changed as per change of other field using javascript.

Now I want jquery event function which can track this change of hidden field and do the needful.

I tried with this :

jQuery("#bannersize").change(function()

but it didnt worked for me as i wanted.

How can i do it?

OM The Eternity
  • 15,694
  • 44
  • 120
  • 182
  • 2
    You have to explicitly trigger the "change" event from your code that changes the field value. No events are automatically generated (by all browsers) when a field value is changed. – Pointy Sep 29 '10 at 13:40

1 Answers1

3

The following should trigger a "change" event. Call this code after you change your hidden field value:

$('#bannersize').trigger('change');
Mike G
  • 4,713
  • 2
  • 28
  • 31
  • +1 Do u mean to place in below html code or above the jQuery("#bannersize").change(function() – OM The Eternity Sep 29 '10 at 14:08
  • 1
    I mean place it wherever you are changing your hidden field value (I'm assuming you have some javascript which changes your hidden field value?) – Mike G Sep 29 '10 at 14:17