return FALSE; $r = well_tag_thread__update(array('id' => $id), $update); return $r; } function well_tag_thread_find($tagid, $page, $pagesize) { $arr = well_tag_thread__find(array('tagid' => $tagid), array('id' => -1), $page, $pagesize); return $arr; } function well_tag_thread_find_by_tid($tid, $page, $pagesize) { $arr = well_tag_thread__find(array('tid' => $tid), array(), $page, $pagesize); return $arr; } ?>javascript - JQuery form update listener - Stack Overflow
最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - JQuery form update listener - Stack Overflow

programmeradmin2浏览0评论

I want to trigger a javascript function when one of the elements in a specific form has been changed. Is this possible using jquery?

Does anybody has an example how to do this?

I want to trigger a javascript function when one of the elements in a specific form has been changed. Is this possible using jquery?

Does anybody has an example how to do this?

Share Improve this question edited Mar 14, 2013 at 8:48 Fortega asked Jun 6, 2009 at 23:05 FortegaFortega 19.7k15 gold badges77 silver badges114 bronze badges 1
  • A -1 4 years after having asked the question? But why? – Fortega Commented Mar 14, 2013 at 8:49
Add a ment  | 

3 Answers 3

Reset to default 2
$(function () { 
  $('form#id input[name=joe]').change( function() { alert('it changed!'); });
} );

If you have a text field like this:

<input type='text' id='myInput'>

You can do this:

function executeOnChange() {
    alert('new value = ' + $(this).val());    
}
$(function() { // wait for DOM to be ready before trying to bind...
    $('#myInput').change(executeOnChange);
});

Here is an example of this in action.

Please note you have to lose focus on the text field in order for the change event to fire.

If you want to select the input by name instead of ID, you can change $('#myInput') to $('input[name=myName]'). For more on selectors, check out the documentation.

Jut write a selector for the items in the form and attach a change handler see http://docs.jquery./Events/change#examples

发布评论

评论列表(0)

  1. 暂无评论