我试图给这个按钮一个div包装器。我怎么做?如果我需要将其转换为html来执行此操作,那么最有效的方法是什么?谢谢
var button = ($('<button>', {
"id": "jspsych-free-sort-done-btn",
"class": "jspsych-free-sort",
"html": "Done",
"style": "text-align:center",
"click": function() {
var end_time = (new Date()).getTime();
var rt = end_time - start_time;
// gather data
// get final position of all objects
var final_locations = [];
$('.jspsych-free-sort-draggable').each(function() {
final_locations.push({
"src": $(this).attr('src'),
"x": $(this).css('left'),
"y": $(this).css('top')
});
});
jsPsych.data.write({
"init_locations": JSON.stringify(init_locations),
"moves": JSON.stringify(moves),
"final_locations": JSON.stringify(final_locations),
"rt": rt
});
// advance to next part
display_element.html("");
jsPsych.finishTrial();
}
}));