Using JQuery within onClick
jquery, onclick
Solution
Sure. jQuery doesn't exist in any special universe; it's just a collection of JavaScript functions that you might find (extraordinarily) useful.
However, if you're using jQuery anyway, why not properly attach the onclick event from within jQuery? You'd just have to do:
$(document).ready(function() {
$("#id-for-that-link").click(function() {
my_save_function($("#inputID").val());
});
});
Problem
Am I allowed to use JQuery within an onClick function? For example: `<a onclick="my_save_function($("#inputID").val())">` `<input type=hidden id="inputID" value="foo">` Such that, when clicked, the anchor tag runs this: `my_save_function(foo);` After a few searches, I couldn't find a similar topic. Thank you for any help.