SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    doRighteousDeeds++
    Join Date
    Aug 2006
    Location
    تركيا Turkey Türkiye
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    When I clicked to the some li element a second time,

    Code:
      
    <script type="text/javascript">
    
    var i = 1;
    function diz (v) {
    
    var e = document.getElementById('katman');
    e.innerHTML  = e.innerHTML + i +v.innerHTML + "<br>" ;
    i++
    }
    </script>
    
    <ul id="liste">
    <li onclick= "diz (this)"> aa </li>
    <li onclick= "diz (this)"> bb </li>
    <li onclick= "diz (this)"> cc </li>
    <li onclick= "diz (this)"> dd </li>
    <li onclick= "diz (this)"> ee </li>
    </ul>
    
    <div id="katman"></div>
    When I clicked to the same li element a second time, it will not write in div. What can I add to the code for this?
    Last edited by muazzez; Jan 9, 2007 at 10:44.

  2. #2
    SitePoint Addict Mirek Komárek's Avatar
    Join Date
    Dec 2006
    Location
    Prague
    Posts
    210
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Firefox Minfield, old FF 0.7, IE5, IE6, Opera 9 all works.

  3. #3
    doRighteousDeeds++
    Join Date
    Aug 2006
    Location
    تركيا Turkey Türkiye
    Posts
    266
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mirek,
    I want this:
    Code:
     
    <script type="text/javascript">
    
    var i = 1;
    function diz (v) {
    
    var e = document.getElementById('katman');
    
    if( e.innerHTML.indexOf(v.innerHTML)==-1)  { 
    
    e.innerHTML  = e.innerHTML + i + v.innerHTML + "<br>" ;  i++  }
    
    }
    </script>
    
    <ul id="liste">
    <li onclick= "diz (this)"> aa </li>
    <li onclick= "diz (this)"> bb </li>
    <li onclick= "diz (this)"> cc </li>
    <li onclick= "diz (this)"> dd </li>
    <li onclick= "diz (this)"> ee </li>
    </ul>
    
    <div id="katman"></div>
    Last edited by muazzez; Jan 10, 2007 at 05:05.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •