var select_tag = $('<select></select>').attr( {
onchange: 'createDiscipline()',
class: 'select_menu'}
).fadeIn('slow');
This works in FF but not Chrome. What happens in Chrome is that the class is set, but the createDisicipline() isn’t.
Is this the wrong way to add multiple attrs to a tag? It does work in FF :/
ENTIRE CODE:
var select_tag = $('<select>', {
onchange: createDiscipline,
'class': 'select_menu'}
).fadeIn('slow');
for(i = 0; i < c_data.length; i++) {
select_tag.append('<option>' + c_data[i] + '</option>');
}
//wrap select_tag in div
var div_buffer = $('<div class=\'select_buffer\'></div>');
var div_container = $('<div class=\'select\'></div>');
div_buffer.append(select_tag).wrap('<div class=\'select_buffer\' />');
div_container.append(heading);
div_container.append(div_buffer);
//Append to the page after right_content id
$('#right_content').append(div_container)
You should definitely not try to bind an event handler like this. Do it the unobtrusive way:
Notice my changes. I wrapped
classin quotes because it is a keyword in InternetExplorer and may break your code otherwise. Also I appended the newly created<select>node to the document.body.Demo: http://jsfiddle.net/vM5Hp/