Search the Community
Showing results for tags 'onclick'.
-
I had such a class : class NodeElement { no; x; y; tre; tdno; tdx; tdy; cbox; nodesArray; nodesTable; selected; constructor( x, y,nodesArray, nodesTable) { nodeCounter++; this.no = nodeCounter; this.x = x; this.y = y; this.nodesArray = nodesArray; this.nodesTable = nodesTable; //create elements this.tre = document.createElement("tr"); this.tre.id = "row"+this.no; this.tdno = document.createElement("td"); this.tdno.id = this.no; this.tdno.innerHTML = this.no; this.cbox = document.createElement("input"); this.cbox.type="checkbox"; this.cbox.id="cbox"+this.no; this.cbox.value=this.no; this.cbox.name="cbox"+this.no; this.cbox.setAttribute('onclick','select(this)'); this.tdx = document.createElement("td"); this.tdx.id="tdx"+this.no; this.tdx.innerHTML = this.x; this.tdy = document.createElement("td"); this.tdx.id="tdy"+this.no; this.tdy.innerHTML = this.y; } } I want to pass complete class object(i.e instantiated one) to a function select() as parameter when I click(i.e. checked the checkbox object of the class instance). My question is that line : this.cbox.setAttribute('onclick','select(this)'); I tried that too : this.cbox.setAttribute('onclick','select("'+this+'")'); but not worked. I could no achieve to pass neither checkbox nor the class object(NodeElement) to function select() as parameter. How can I do that?
-
I've got a bit of jQuery that is getting the bit of data that I want to search the page for. This is posted below. $(".pagelink").click(function(){ var myClass = this.className; var number = myClass.substr(myClass.length - 1); }); This bit is working ok. It gets the last bit of the element's class name which is a number incremented by the PHP that echoes it out. Now I want to search the page for a div that has a class that contains that var number. There will be a div somewhere on the page with a class that contains that number. It will be called either row0, row1, row2, row3 etc etc. The div is not a descendant element of the pagelink class, it is somewhere else so I don't think the find() variable is suitable. Any help will be greatly appreciated, thanks!