Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
html/js question
#2
Err, innerHTML is a property of the HTMLElement object or something like that. What you want is a method that sets the innerHTML and returns the object?

I'm pretty sure you can extend the HTMLElement (or whatever it is) class and define your own method to do just that, but I don't know/recall how.

Edit: Quick Google search tells me you want something like
Code:
HTMLElement.prototype.setInnerHTML = function(stuff) {
var element = this;
element.innerHTML = stuff;
return element;
}

Then you'd just go
Code:
getElementById('test').setInnerHTML('sample').doFunctionHere();

Edit:
 Yah, it works.

Edit again:
But apparently this doesn't work in IE, and you have to do this?
Reply


Messages In This Thread
html/js question - by butterfλi - 2009-06-21, 09:22 PM
html/js question - by Russt - 2009-06-21, 09:48 PM
html/js question - by butterfλi - 2009-06-21, 10:25 PM
html/js question - by Russt - 2009-06-21, 10:42 PM
html/js question - by butterfλi - 2009-06-21, 10:49 PM
html/js question - by Russt - 2009-06-21, 11:00 PM
html/js question - by butterfλi - 2009-06-22, 02:02 AM
html/js question - by Russt - 2009-06-22, 02:17 AM
html/js question - by butterfλi - 2009-06-22, 11:30 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)