Beldion Bryan Balanan Beldion Bryan Balanan - 5 months ago 8
Javascript Question

Jquery .css to change one style

$(document).on('click', '.close-link', function(){
$(this).parent().parent().parent().parent().remove();
$(document).find("#followdiv").( "top", "0px" );
});


I am trying add a style to
<div id="followdiv">
so that it becomes
<div id="followdiv" style="top: 0px;">
. I used this http://api.jquery.com/css/ as reference for the code above and I dont know why it won't work.

Answer

You can use

$(document).ready(function(){        
    $('.close-link').on('click', function() {
        $(this).parent().parent().parent().parent().remove();
        $('#followdiv').css( "top", "0px" );    
    });
});

Your div has an id so you can target it directly with jQuery. Also you don't have to use .parent().parent().parent().parent(), there is .closest() you can use