Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I have this code which runs perfectly on jsFiddle. When I try to run that code on my self-hosted WordPress site, however, it will not run. (The code is exactly the same on my page, except that I added <script type="text/javascript" src="/files/jquery-1.8.3.min.js"></script> before the Javascript on the page.) The Javascript is directly in the Text tab of my page, JS first followed by the HTML. The form loads properly, but clicking the "Add Row" button does nothing.

I had this issue on another page on my site, but it was fixed by wrapping everything in

$j(document).ready(function(){
    // code
});

and using jQuery noConflict mode. I implemented that here (as you can see in the code), but it is not working.

share|improve this question

1 Answer 1

up vote 0 down vote accepted

As for me, in WP I always use jQuery instead noConflict mode, Try to run this code: http://jsfiddle.net/GKmvA/1/

share|improve this answer
    
I just tried that and it unfortunately did not work. –  Vaindil Dec 20 '12 at 2:54
    
could you post here what FireBug (or Chrome Inspector) said? Do you see eny error? Put <code>alert('It works');</code> before JS-code. Do you see alert after page refresh? –  Maxim Orlovsky Dec 20 '12 at 2:56
    
Sorry, I should've done that. I'll edit my original post, but it says Uncaught SyntaxError: Unexpected token < on line 175. Line 175 is var rows = 1;, but WordPress autoformats it to display a </p> after the line (so var rows = 1;</p>). After removing all of the whitespace and linking it as a .js file (instead of directly embedding), it now works. Thank you! –  Vaindil Dec 20 '12 at 3:04
    
You are welcome –  Maxim Orlovsky Dec 20 '12 at 3:21

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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