Levi Villarreal Levi Villarreal - 5 months ago 7
jQuery Question

Jquery .click not working when changing css properties

I have this html,

<h2 class="more-button">Read More</h2>


and am trying to have it change the position of another div when it is clicked. To accomplish this I am using

$(".more-button").click(function(){
$(".hidden-block").css("right", "110%");
});


FIDDLE : https://jsfiddle.net/wfxxkk3x/

But the code does absolutely nothing. I have tried many different approaches with this problem and nothing seems to work. Any help would be appreciated.

Answer

Change the selector of the hidden-block from a class to an id

$(".more-button").click(function(){
$("#hidden-block").css("right", "110%");});

https://jsfiddle.net/wfxxkk3x/5/

or use animate to animate the div

https://jsfiddle.net/cjon7apg/