Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <ul id="thelist">
<div id = "lst"></div>          
</ul>
</body>
</html>
 
  function itemclicked(id) {
        alert("clicked at :"+id);
        var el = document.getElementById(id);
        var pElement = el.contentText || el.innerText;
        alert("value of this is: " + pElement);
    }
    
    function callAlert()
        {
    
    
            //get number of rows to create
            listRows = prompt("how many list row you want??");
            listRows = parseInt( listRows, 10 );
          
            var listText = "List Number";
    
                    for(var i = 0;i < listRows; i++)
                    {
                        if(i%2==0)
                        {
                            listText = listText +i+'<p style="background-color:#EEEEEE" id = "listNum' + i + '" onclick = "itemclicked(id)">';
                        }                   
                        else
                        {
                            listText = listText + i+ '<p  id = "listNum' + i + '" onclick = "itemclicked(id)">';
                        }                                   
                        listText = listText + i;
    
                        //document.getElementById("lst").innerHTML = listText+i+'5';
                    }
                    document.getElementById("lst").innerHTML = listText+i;
        }
    callAlert();
Output 300px

You can jump to the latest bin by adding /latest to your URL

Dismiss x
public
Bin info
brunomartinspro
0viewers