• Resolved pieterw3

    (@pieterw3)


    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.

Viewing 13 replies - 1 through 13 (of 13 total)
  • WPyogi

    (@wpyogi)

    Thread Starter pieterw3

    (@pieterw3)

    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="https://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.)

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Have you tried using the syntax;

    jQuery(document).ready(function(){
    
    });

    Thread Starter pieterw3

    (@pieterw3)

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

    Thread Starter pieterw3

    (@pieterw3)

    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)

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Did you resolve the issue?

    Thread Starter pieterw3

    (@pieterw3)

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

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    You still have incorrect syntax.
    Use my example.

    Thread Starter pieterw3

    (@pieterw3)

    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

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    You don’t have anything in the function

    Thread Starter pieterw3

    (@pieterw3)

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

    now i added the .height code from my previous post

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

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

    Thread Starter pieterw3

    (@pieterw3)

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

Viewing 13 replies - 1 through 13 (of 13 total)
  • The topic ‘Adding custom javascript file and jqeury’ is closed to new replies.