I have this javascript function and i qould to create a jquery selector, which was build from js function parameter value:
function myJSFunction(elementId){
var showSomeData= {
'value_1': 'abc',
'value_2': 'xyz'
};
var selector = "[name=" + elementId + "] option";
jQuery("'" + selector + "'").each(function() {
$(this).attr('title', showSomeData[$(this).val()]);
});
};
But this kind of code doesn´t work. If i set the concrete value, which i can see in the html dom by using firebug, this code works fine. What was my mistake?
Instead of using $("'" + selector + "'")
use $(selector)
and your issue is solved.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments