javascript
  • onclick
  • 2011-03-18 66 views 3 likes 
    3

    爲什麼這不起作用?內嵌onclick事件中的對象

    <img id="xx" src="/Content/components/imgs/add.gif" onclick='ShowLookup({"id": "22","name": "Robert Pitt"})' /> 
    

    <img id="xx" src="/Content/components/imgs/add.gif" onclick='ShowLookup("id": "22","name": "Robert Pitt")' /> 
    

    當我點擊圖片,我得到了一個錯誤:無效的屬性ID

    +1

    你能向我們展示你的'ShowLookup'功能? – 2011-03-18 12:17:16

    +0

    ShowLookup現在是空的。當我蹲在圖像上時發生錯誤 – user256034 2011-03-18 12:18:38

    +0

    爲什麼你想在那裏使用一個對象?該功能可能需要正常的參數。否則嘗試ShowLookup(新{「id」:「22」,「name」:「Robert Pitt」}) – Rob 2011-03-18 12:20:31

    回答

    3

    就像一個魅力對我來說:

    http://jsfiddle.net/neebz/uwywG/1/

    +0

    只能在IE8和Chrome中使用。在FF – Rob 2011-03-18 12:30:00

    +0

    中沒有答覆。 FF沒有顯示'圖片未找到'標識。 – neebz 2011-03-18 12:33:38

    相關問題