Jake
Jake

Reputation: 3486

Javascript Code not working when on my site

I recently installed a code on my website to insert text at the position of the cursor. It works perfectly when on its own: http://www.penpalparade.com/test.php

It isn't however working with my site as a whole: http://www.penpalparade.com/jobs.php

I've tried to fix it but have been unsuccessful, could someone please please help me at solving it because I've been at it for hours.

Upvotes: 0

Views: 287

Answers (1)

Kris Krause
Kris Krause

Reputation: 7326

Firebug is showing several errors.

$(".tooltipbox a[title]").tooltip is not a function

jQuery("textarea[class*=expand]").TextAreaExpander is not a function

"NetworkError: 404 Not Found - http://www.penpalparade.com/css/images/img02.jpg"

This code is referenced before jQuery:

<a href="javascript:;" onclick='$("#message").insertAtCaret("*****");'>*****</a>

To get it out the door move your jquery src reference to the top (in the head tag).

Or to do it correctly. Just above your closing body tag:

$(document).ready(function() {
  $("#whatever").click(function() {
     $("#message").insertAtCaret("*****");
  });
});

Change your Html to:

<a id="whatever" href="">*****</a>

This allows you to separate the behavior from the content.

Upvotes: 4

Related Questions