2

I have this jfiddle working (http://jsfiddle.net/FJxcG/), but the same code does not work on my Drupal 7 website. I added the JS file to my theme .info file, and the JS is showing up in the source; it's just not displaying the end result on-screen.

The reason I need this is so that I can wrap a span class around all instances of the Trademark special character (™). That character is too large in the font I am using, and I'd like to use that css/jquery function to apply the span so I can give the TM a smaller font size without affecting the rest of the text around it. Some of the TM's are within menu links, so I can't simply hard-code the new span class.

Thanks!

2

Two things I can think of that could possibly cause the problem:

  1. Your code runs before the document is fully loaded. To fix it try wrapping the function call inside $(document).ready:

    $(document).ready(function() {
      $('div').wrapInTag({
        words: ['™'],
        tag: '<span class="trademark">'
      });
    });
    
  2. The CSS style are being overridden. Quickfix would be to add !important at the end.

    .trademark {
      font-size: 9px !important;
      vertical-align: top !important;
    }
    
  • It looks like #1 was the solution. Unfortunately, making this JS work cause my jquery drop-down nav functionality to stop working. Also, I could not get the code to properly recognize the trademark symbol... I tried ™, &trade; , and &#153; and none of them worked. Oh well, I suppose I will just live with the large 'TM' for now. Thanks for your help! – hockey2112 Mar 29 '13 at 2:56
  • There might be an error in the code if other javascript functionality breaks. Errors can also cause the script itself to not work. You could try debugging and fixing the problems if any exist. Other than that there's also Google and the Stack Overflow site that may help you figure out a working solution. The problem is probably not Drupal related so Stack Overflow might get you a better result. – Madis Mar 29 '13 at 9:23

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.