NOTE: This entire question was based off a scenario where the issue was a syntax error; there was actually NO issue with passing 'this'. The question should be closed.
For example, the following works:
$('.base-icons').click(function () {
selectedIcon($(this).attr("src").split(/\/(\/*)/));
});
var selectedIcon = function(myObj) {
console.log(myObj);
};
And prints the shortened string as expected. The follow does not work:
$('.base-icons').click(function () {
selectedIcon(this);
});
var selectedIcon = function(myObj) {
console.log($(myObj).attr("src").split(/\/(\/*)/)[6]);
};
as it prints undefined
. Why? Thank you.