jeudi 25 février 2016

using if else statement in js to check to see if an html form element is equal to a certain number

I've javascript code that allows users to load more posts, and i want to use if else statement to check to see if an html form element is equal to a certain number then the click function would transfer the user to another html page.. here is the html code

<ul id="myList">

<li>One</li>
<li>Two</li>
<li>Three</li>
<li>Four</li>
<li>Five</li>
<li>Six</li>
<li>Seven</li>
<li>Eight</li>
<li>Nine</li>
<li>Ten</li>
</ul>
<div id="loadMore">Load more</div>

and the js code

$(document).ready(function () {
    size_li = $("#myList li").size();
    x=3;
    $('#myList li:lt('+x+')').show();
    $('#loadMore').click(function () {
        x= (x+5 <= size_li) ? x+5 : size_li;
        $('#myList li:lt('+x+')').show();
         $('#showLess').show();
        if(x == size_li){
            $('#loadMore').hide();
        }
    });

as you can notice

if(x == size_li){
                $('#loadMore').hide();

i want it to transfer the user instead of hide it

Aucun commentaire:

Enregistrer un commentaire