Been trying to add a custom error notice with jquery, but so far the div looks funky

jQuery('h1').prepend('<div class=\"error\">Start</div>');

Any tips how to get this to work? As I understand Drupal uses the error div.


Drupal uses messages as the 'base' class for messages so this should work:

jQuery('h1').prepend('<div class="messages error">Start</div>');

Note that you shouldn't escape double quotes inside a string unless the string is actually wrapped in double quotes.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.