The function variable 'data' is formatted like this: 0,70; but I need to separate this at the comma so I have two different variables from the one string. I'm trying to do this using split() but it's not working and stops the rest of the code from working. I don't know any alternatives to split other than substr, and it is not working either. $('#chart').bind('jqplotDataHighlight', function(ev, seriesIndex, pointIndex, data){ var myArray = data.split(','); $('#tooltip').text('This is your score: ' + myArray[0]); }); Code (markup):
It seems fine, so I think the problem is somewhere else. This example might help you spot it: <html> <head> <script type='text/javascript' src='http://code.jquery.com/jquery-1.4.2.min.js'></script> <script type='text/javascript'> $(document).ready(function() { $('#chart').bind('jqplotDataHighlight', function(ev, seriesIndex, pointIndex, data) { var myArray = data.split(','); $('#tooltip').text('This is your score: ' + myArray[0]); }); $('button').click(function () { $('#chart').trigger('jqplotDataHighlight', [ 0, 0, '0,70;' ]); }); }); </script> </head> <body> <div id='chart'>Chart</div> <p id='tooltip'>Tooltip</p> <button>Trigger Event</button> </body> </html> Code (markup):