How do you create a function in jQuery, call it, and pass a variable to it? Here it is in Javascript style:
<script type=text/javascript>
function popup(msg) {
alert(msg);
}
</script>
Then you would simply include the event in the HTML:
<html>
<input type=submit onclick=popup('My Message') />
</html>
What is the jQuery equivalent to doing this? From all the newbie tutorials, they are all static functions that do not accept variables. For example:
<script type=text/javascript src=jquery.js></script>
<script type=text/javascript>
$(document).ready(function() {
$('button').click(function() {
alert('hello, world');
});
});
</script>
I want to be able to dynamically include different messages. The code above affects all buttons and spits out the same message of 'hello, world'.