Reputation: 1192
Modifying a jQuery plugin, I have lines of code as follows:
var currentread = (self).find('.c'+a).html();
//currentread = currentread.toUpperCase();
$('#output').html(currentread);
With the middle line commented out, the code works fine. The contents of the div with the class 'c[1-n]' is displayed in #output. Uncommenting the middle line to convert this to upper case, however, generates the error 'currentread is null' for that line.
I must be doing something stupid here, but this doesn't seem to make sense. Any idea?
Upvotes: 2
Views: 5013
Reputation: 37761
Is is simply the case that currentread
is null? You could change it to:
currentread = (currentread || "").toUpperCase()
so that toUpperCase is always called on a string.
Upvotes: 9