简体   繁体   中英

What's wrong with this JavaScript object literal assignment?

Perhaps I'm just being dense, but I don't understand why Netbeans is telling me this is bad syntax:

var events = {
    'onkeyup'  : 0,
    'onchange' : 0,
    'onclick'  : 0
};

Lines 2-4 are squiggled red.

I did a quick test in my netbeans 6.9, and i did not get any warnings or errors. You should probably try and install the "Web Applications" plugin and see. Which version are you using?

D'oh! I failed to realize that this JavaScript is being parsed by PHP and contains some PHP code prior to the object literal assignment. Apparently the JavaScript Debugger is not too happy about statements like:

var foo = <?php print $bar ?>;

Go figure. :P

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM