开发者

show and hiding order list

开发者 https://www.devze.com 2023-01-18 16:21 出处:网络
String+ if user click the + sign i want to show some oder list thenString - If the user click the - sign i want to hide order l开发者_如何转开发ist

String +

if user click the + sign i want to show some oder list

then String -

If the user click the - sign i want to hide order l开发者_如何转开发ist

How to acheive this with javascript , not using ajax , jquery


You will have to create an id for the ordered list, e.g.

<ol id="superId">


</ol>

then on javascript

function displayOL(enabled) {
  if (enabled) {
     document.getElementById("superId").style.display = "none";
     document.getElementById("minus").style.display = "block";
     document.getElementById("plus").style.display = "none"; 
  } else {
     document.getElementById("superId").style.display = "block"
     document.getElementById("minus").style.display = "none";
     document.getElementById("plus").style.display = "show";
  }
}

then on anchor tag

<a href="#" onclick="displayOL(true)" id="plus">+</a>

<a href="#" onclick="displayOL(false)" id="minus">-</a>

PS....I just did a rough implementation in no order....


try this and attached it to your any event, i.e. onclick, onmouseover, etc...:

function toggleList(elem){
var theList = document.getElementById(elem);

if(theList.style.display == "none"){
    theList.style.display == "block";
}
else{
    theList.style.display == "none";
}
}

This method can be used for anything you want to show/hide. Obviously, you can call the function and variable anything you like that makes sense...

0

精彩评论

暂无评论...
验证码 换一张
取 消