Executing scripts in stimulus in html-button-response #3206
-
hi, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I should think not, as that is specified by HTML:
But you do not really need external-html. I mean, external html is generally for cases where seriously complex html is needed. But for a simple case like what you have described, you can simply set the basic html in Here's a simplified example: let trial = {
type: jsPsychHtmlKeyboardResponse,
stimulus:
'<p id="target">1</p>' +
'<input type="button" id="button-1" value="1">' +
'<input type="button" id="button-2" value="2">' +
'<input type="button" id="button-3" value="3">',
on_load: function () {
document.querySelector("#button-1").addEventListener("click", function () {
document.querySelector("#target").innerHTML = 1;
});
document.querySelector("#button-2").addEventListener("click", function () {
document.querySelector("#target").innerHTML = 2;
});
document.querySelector("#button-3").addEventListener("click", function () {
document.querySelector("#target").innerHTML = 3;
});
},
}; |
Beta Was this translation helpful? Give feedback.
I should think not, as that is specified by HTML:
But you do not really need external-html. I mean, external html is generally for cases where seriously complex html is needed. But for a simple case like what you have described, you can simply set the basic html in
stimulus
and add whatever interactive function you might want inon_load
.Here's a simplified example: