Wednesday 15 May 2013

javascript - Triggering events and binding in jquery -



javascript - Triggering events and binding in jquery -

i new jquery , have been playing around it. have:

<fieldset id="question-7"> <p> <label>question 7</label> </p> <p> need custom event named "profileupdated". bind event , create word "updated" appear in output div when triggered. trigger event when <a href="#">link</a> clicked. </p> <p class="output"> </p> </fieldset>

and jquery is:

function profileupdated() { $( "#question-7" ).bind( "link", function() { alert( $( ).text('updated') ); }); });

i'm not sure doing wrong.

first of there no event called "link" @dfsq said, for more flexible event binding can utilize .on() or .delegate()

example :

$(document).ready(function(){ $('#question-7').on('click',function(){ alert($(this).text()); } }

javascript jquery

No comments:

Post a Comment