문제

When the page loads I need #book to take 80% width of the window, and the same need to happen when page is resized. I make the code bellow, but it doesn't work. Why?

<script type="text/javascript">
    $(document).ready(function(){
        $('#book').turn();
        $("#book").width = 80 + "%";
    });
    $(document).resize(function(){
        $('#book').css('width', '80%');
    });
</script>

Thanks!

도움이 되었습니까?

해결책

$("#book").width = 80 + "%"; isn't correct JS/jQuery.

You can change it to either

$('#book').css('width', '80%'); 

or

$('#book').width('80%');

Also, use $(window).resize() instead of $(document).resize()

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top