Skip to content
Discussion options

You must be logged in to vote

This doesn't work because the jQuery function is called before the paragraph is added to the display. When the jQuery function is called, there are no elements of class clickable on the screen.

You could move the function into the on_load event of the plugin:

var select_text_trial = {
  type: "html-keyboard-response",
  stimulus: '<p class="clickable">The objective can also be achieved by simply analysing the string.</p>',
  on_load: function(){
    $('.clickable').click(function() {
      	var sel=window.getSelection();
     	var str=sel.anchorNode.nodeValue,len=str.length, a=b=sel.anchorOffset;
      	while(str[a]!=' '&&a--){}; if (str[a]==' ') a++; // start of word
  	while(str[b]!=' '&&b

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by nrschoen
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants