Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Attaching event lisener with arguments.

Attaching event lisener with arguments.

Scheduled Pinned Locked Moved Web Development
javascripttoolshelpquestion
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • 2 Offline
    2 Offline
    2489128
    wrote on last edited by
    #1

    Hi All! I've following table in my web page: <table id="tblTest"> <tr> <td> dfdf</td> <td> dfdf</td> </tr> <tr> <td> sfds</td> <td> fdsf</td> </tr> </table> i've put following javascript code in script tag: window.onload = function() { var Trs = document.getElementById('tblTest').children[0].children; for(var n=0; n<Trs.length; ++n) if(document.addEventListener) Trs[n].addEventListener('click', function(){ Information(Trs[n], Trs[n].children.length); }, false ); else if(document.attachEvent) Trs[n].attachEvent('onclick', function(){ Information(Trs[n], Trs[n].children.length); } ); } function Information(tr, trCount) { alert(tr.nodeName); alert(trCount); } but on clicking on any row following javascript error raised: Microsoft jScript runtime error: 'Trs[...].children' is null or not an object can any body tell me where i have made mistake?

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups