I started to learn Jquery and but I am having trouble understanding function parameters:(
If you look my first code and run it: my script WILL work (WITHOUT parameters). And if you look my second code
(WITH parameters) and run it: second script WILL ALSO WORK!!
My first question: Did I correctly set parameter in my second script?
Second question: How can I check is my parameter set or being passed correctly to my function?
P.S. Sorry for being NOOB and THANK YOU!!
//First code (WITHOUT PARAMETERS!!!)
$(document).ready(function () {
var addclass = $('p:first');
function AddClass() {
addclass.addClass('first');
if (addclass.is($('.first'))) {
alert('here');
}
else {
alert('not here');
}
}
$('.button').click(function () {
AddClass(addclass);
});
});
//Second code (WITH PARAMETERS)
$(document).ready(function () {
var addclass = $('p:first');
function AddClass(addclass) {
addclass.addClass('first');
if (addclass.is($('.first'))) {
alert('here');
}
else {
alert('not here');
}
}
$('.button').click(function () {
AddClass(addclass);
});
});