I want to add an argument of a function to a string (iam not sure if thats the right word)
function changeChart(form, chart, bar) {
//chart 2 (left)
$(form).change(function (){
console.log(form);
$(form + "option:selected").each(function(){
//rest of the function
I want the form added to the selection in Jquery.
Is this the right way?
If
formis a string, you need to be sure there’s a space before"option:selected".If
formis an element, pass it to the jQuery functin, then usefind:Or use the context parameter (though IMO the code is less clear):
Although, since you’re in the handler, you could just use
thisto reference the form element.