hiiii
hiiii

Reputation: 349

call javascript function from jquery

I inherited some javascript code. One of them is a function chg(x) which reloads the page after a drop down list's value has been changed.

How do I use jquery to change the drop down list's value and call chg(x) when the value is changed ?

Upvotes: 0

Views: 123

Answers (2)

meder omuraliev
meder omuraliev

Reputation: 186562

You should be able to call chg anywhere where it's valid to call a function, since jQuery IS Javascript.

If chg() doesn't work, then provide us with some code specific to your situation, because it may not be defined in global context or scope such to call it like that.

Upvotes: 1

Fabiano
Fabiano

Reputation: 5199

Use the .change method:

$('#myDropdownID').change(function() {
  $(this).val('some value'); //will change the dropdown's selected value to whatever you want
  chg(x);
});

Assuming that the chg() function is somewhere in the code.

More references here: .change() jquery method

Upvotes: 1

Related Questions