javascript - Why can't I call this object's function from an in-line anchor? -
html:
<a href="javascript:alert('hey.')">alert</a><br/> <a href="javascript:alert('in anchor:\n' + objection.sustained());">alert</a>
javascript:
var objection = { sustained : (function() {return ("accroches-toi ton reve")}) }; alert("in script: \n" + objection.sustained()); $("outdat").text( +"<br/>\n");
just curious here, why can't call objection.sustained()
anchor tag, it's ok script region?
it seems not know object exists when using anchor. happens in several major browsers believe design?
variable scope.
fiddle placing variable in document load scope you're anchor code can not see it. @kjy112 mentioned, remove code blocks , should work fine.
Comments
Post a Comment