Ready to get started?Download WordPress


Error implementing JQuery (1 post)

  1. inprojectcloud
    Posted 1 year ago #


    I am trying to implement a jquery code onto my website. The code I am using is based on http://jsfiddle.net/karalamalar/grnQA/

    This is what I have done:

    A. Created a Folder called JS in my theme. Inside I created a file called share.js and inserted the following code:

    [ Code edited with backticks. Moderator note: when sharing code examples, please wrap the code in backticks or use the code button. ]

    jQuery(document).ready(function($) {
    function fixDiv() {
    var $cache = $('#getFixed');
    if ($(window).scrollTop() > 100)
    $cache.css({'position': 'fixed', 'top': '10px'});
    $cache.css({'position': 'relative', 'top': 'auto'});

    B. I edited the functions.php file by adding the following code:

    function insert_jquery() {
    'share', // name your script so that you can attach other scripts and de-register, etc.
    get_template_directory_uri() . '/js/share.js', // this is the location of your script file
    array('jquery') // this array lists the scripts upon which your script depends

    C. I edited the CSS by adding the following code:

    #getFixed { color: #c00; font: bold 15px arial; padding: 10px; margin: 10px; border: 1px solid #c00; width: 200px; }

    D. I edited the single post file with the following code:

    <div id="getFixed">This div is going to be fixed</div>

    What I get: http://beta.projectcloud.info/nirma-university-law-journal-volume-ii-issue-ii/

    I can view the the message but the jquery is not working. Ideally it would stay at the top of the screen. Any inputs?

Topic Closed

This topic has been closed to new replies.

About this Topic