jquery - JavaScript function problems -
i can't display alert fed function argument. have compared examples , can't see problem causing not work. have included html , javascript below, in i'm going wrong gratefully received. a
html:
<!doctype html> <html> <head> <meta charset="utf-8"> <title>untitled document</title> <script src="http://code.jquery.com/jquery.js"></script> <script src="testjs.js"></script> </head> <body> <div id = "testbed"> <a id = "testlink" href = "#number1">test click</a> </div> </body> </html> javascript:
$(document).ready(function() { $.fn.newmodalcontrols = function(modelspec) { alert(modelspec); } // end newmodalcontrols $('#testlink').click(function() { $(this).parent().newmodelcontrols('number1'); }); // end testlink click function }); // end ready
you have typo. change newmodelcontrols newmodalcontrols.
javascript
$(document).ready(function () { $.fn.newmodalcontrols = function (modelspec) { alert(modelspec); } $('#testlink').click(function () { $(this).parent().newmodalcontrols('number1'); }); }); update: added jsfiddle example.
Comments
Post a Comment