I'm creating a profiles page in javascript/jquery and I'm using a carousel of div's to accomplish said task. The question I have is, how do I programmatically access each style.display or $("#username").hide() or .show() ?
function changeProfile(num) { var profiles = $('#profiles'); if (num < 1) { index = 3; } if (num > 3) { index = 1; } for (i = 0; i < 3; i++) { profiles[i].style.display = "none"; // error here // for example: $('#profiles')[0]; etc } profiles[index - 1].style.display = "block"; console.log("Profile number: " + index); }
<div class="profiles"> 1 / 3 <img src="images/blank1.jpg" style="width:90%"> </div> <div class="profiles"> 2 / 3 <img src="images/blank2.jpg" style="width:90%"> </div> <div class="profiles"> 3 / 3 <img src="images/blank.jpg" style="width:90%"> </div>
没有评论:
发表评论