0

It is loaded on clicking prev button. I want to disable this button when there is no more articles. Preferably i would like button to disappear.

function getPrev(item, article) {
  for (var i = 0, len = article.length; i < len; i++) {
  if (article[i].id === item) {
    return (i - 1 >= 0) ? article[i - 1] : null;
  }     
}

Thanks

2 Answers 2

2

if you want to hide your button, use

$("#buttonid").hide();

If you want to disable it,

$("#buttonid").prop("disabled",true);
Sign up to request clarification or add additional context in comments.

Comments

1

What you can do is -

document.getElemenyById('buttonid').style.display = 'none';

1 Comment

Just remember to set the style to 'block' when there are articles

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.