Я пытаюсь дать этой кнопке обертку div. Как мне это сделать? И если мне нужно преобразовать его в html, чтобы сделать это, что является наиболее эффективным способом? БлагодаряПреобразование элемента jquery в 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();
}
}));
Спасибо за ответы. Причина, по которой я хотел, чтобы обертка div была сосредоточена на кнопке. Но button.wrap ("
"); похоже, не работает. Есть предположения? – mlawsonca