WordPress.org

Forums

[resolved] Adding custom javascript file and jqeury (14 posts)

  1. pieterw3
    Member
    Posted 3 years ago #

    i want to use some custom .js file with jquery.

    how do i add the javascript exactly? ( i saw this )

    but i don't really now where to add it, do i just add it in my div? or should i add it in my functions.php? and do i need to add the jquery script to.

    the script should work on every page. it is to style a div which is included in the header.

  2. WPyogi
    Forum Moderator
    Posted 3 years ago #

  3. pieterw3
    Member
    Posted 3 years ago #

    yeah but isn't it better to add it with the link i provided,

    NOTE:
    i did try i though but it didn't work i only added my .js though, should i add jquery to? and if how?

    on my website i see that jquery is loaded. see below:

    <script type="text/javascript" src="http://itsolutionsblog.net/wp-includes/js/jquery/jquery.js?ver=1.8.3"></script>

    but when i for instance in my .js say:

    jQuery(document).ready ('function'(){
    alert('Hellow World');
    });

    it doesn't work. (this was just an example alert though i tried some different jquery actions to.)

  4. Andrew Nevins
    Forum moderator
    Posted 3 years ago #

    Have you tried using the syntax;

    jQuery(document).ready(function(){
    
    });
  5. pieterw3
    Member
    Posted 3 years ago #

    oh my bad in my code the ' aren't there. somewhat of a beginner with coding ^^

  6. pieterw3
    Member
    Posted 3 years ago #

    I don't now if it is any help but the site i am doing this for is ITsolutionsblog.net

    i added the javascript in the div with id topbar ( it is the div above the menu)

  7. Andrew Nevins
    Forum moderator
    Posted 3 years ago #

    Did you resolve the issue?

  8. pieterw3
    Member
    Posted 3 years ago #

    no i did not, i meant in my original code there are no ' (i made that mistake only here)

  9. Andrew Nevins
    Forum moderator
    Posted 3 years ago #

    You still have incorrect syntax.
    Use my example.

  10. pieterw3
    Member
    Posted 3 years ago #

    topbar.js
    now it as in your example(copied). but when i add an alert. ore for example

    Jquery('.topbar').height(100);

    it still does not work. this code should work right?

    code as it is now : here

  11. Andrew Nevins
    Forum moderator
    Posted 3 years ago #

    You don't have anything in the function

  12. pieterw3
    Member
    Posted 3 years ago #

    i deleted it but i guess i took you to seriously with use my example :P

    now i added the .height code from my previous post

  13. Andrew Nevins
    Forum moderator
    Posted 3 years ago #

    Wrong syntax again. Look how I've referenced jQuery compared to how you have.

  14. pieterw3
    Member
    Posted 3 years ago #

    ah spotted it. it all works now. i feel kinda stupid though!
    Thanks!

Topic Closed

This topic has been closed to new replies.

About this Topic