• Hi,
    I have problem with jQuery ,He not working but working there some other
    that I do not have funciton in my script file.
    There is my function.php
    `add_action( ‘wp_enqueue_scripts’, ‘my_custom_scripts’ );
    function my_custom_scripts()
    {
    wp_deregister_script(‘jquery’);
    wp_register_script(‘jquery’, ‘https://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js’, array(), false, false);
    wp_enqueue_script(‘jquery’);

    wp_enqueue_script(‘myscript’, get_template_directory_uri() . ‘/scripts.js’, array(‘jquery’), false, true);
    }`
    And there is my scripts.js

    jQuery(document).ready(function($){
    
    	    $("nav ul li").hover(function () {
                $(this).find("ul").fadeToggle(400);
            },
    
    	});

Viewing 6 replies - 1 through 6 (of 6 total)
  • Check for a few things:

    • Is your jQuery being included correctly?
    • Are there any errors in browser console?

    Also, giving your site’s URL will be helpful too.

    Thread Starter 17Mark

    (@17mark)

    My jQuery code who insert jQuery is top in my first post. Browser console writes nothing but when I writing to console jQuery, she give me only this: function n()

    Thread Starter 17Mark

    (@17mark)

    I try reload page and console writing this:

    GET
    https://clients5.google.com/pagead/drt/dn/dn.js [HTTP / 2.0 200 OK 0ms]
    GET
    http: // localhost / wordpress / [HTTP / 1.1 200 OK 0ms]
    GET
    http: //localhost/wordpress/wp-content/themes/okna-dvere-zasklenia/css/font-awesome.min.css [HTTP / 1.1 200 OK 0ms]
    GET
    http: //localhost/wordpress/wp-content/themes/okna-dvere-zasklenia/style.css [HTTP / 1.1 200 OK 0ms]
    GET
    https://ajax.googleapis.com/ajax/libs/jquery/2.2.0/jquery.min.js [HTTP / 2.0 200 OK 0ms]
    GET
    http: //localhost/wordpress/wp-includes/js/wp-embed.min.js [HTTP / 1.1 200 OK 0ms]
    Unknown property '-moz-osx-font-smoothing'. Declaration omitted. font-awesome.min.css: 4: 660
    Expected 'none', or URL address filtering function, but found 'progid'. Error parsing value for the 'filter'. Declaration omitted. font-awesome.min.css 4: 1899
    Expected 'none', or URL address filtering function, but found 'progid'. Error parsing value for the 'filter'. Declaration omitted. font-awesome.min.css 4: 2062
    Expected 'none', or URL address filtering function, but found 'progid'. Error parsing value for the 'filter'. Declaration omitted. font-awesome.min.css 4 2228
    Expected 'none', or URL address filtering function, but found 'progid'. Error parsing value for the 'filter'. Declaration omitted. font-awesome.min.css 4 2399
    Expected 'none', or URL address filtering function, but found 'progid'. Error parsing value for the 'filter'. Declaration omitted. font-awesome.min.css 4: 2572
    GET
    http: //localhost/wordpress/wp-content/themes/okna-dvere-zasklenia/scripts.js [HTTP / 1.1 200 OK 0ms]
    Error processing the values ??for 'padding'. Declaration omitted. style.css: 25: 10
    When reading 'first-child (' token found for function pseudo-class or pseudo-element functions, or vice versa. The rules ignored due to bad selector. Style.css: 70: 18
    Error parsing value for 'background-color'. Declaration omitted. style.css: 79: 0
    GET
    http: //localhost/wordpress/wp-includes/js/wp-emoji-release.min.js [HTTP / 1.1 200 OK 0ms]

    Everything looks good. Do you have a public link for this site?

    Thread Starter 17Mark

    (@17mark)

    Can be problem in the JS code or CSS?
    This is from style.css:

    nav ul ul.sub-menu {
    	position: absolute;
    	margin-top: 20px;
    	display: none;
    }
    
    nav ul li {
    	list-style-type: none;
    	margin: 0;
    	padding: 0;
    	display: inline-block;
    	float: left;
    }
    
    nav ul li a {
    	display: block;
    	color: #757575;
    }
    
    nav ul li ul li {
    	float: none;
    	display: block;
    }
    
    nav ul li a:hover{
    	border-bottom: 5px solid #2b81eb;
    }
    
    nav ul li ul li a {
    	padding: 10px 30px;
    	background: #cccccc;
    }
    nav ul li ul li a:hover{
    	border: none;
    	padding: 10px 30px;
    }

    And here is scripts.js

    jQuery(document).ready(function($){
    
        $( 'nav ul li a' ).hover(
            function(){
                $(this).children('ul.sub-menu').slideDown(200);
            },
            function(){
                $(this).children('ul.sub-menu').slideUp(200);
            }
        );
    });

    Also here is screen from firefox style editor:
    https://postimg.org/image/j24nrb4mt/

    Thread Starter 17Mark

    (@17mark)

    No I have not public link, it is only on virtual server which i have install on my PC

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘My custom Javascript isn' t working’ is closed to new replies.