Re: [問題] 用jQuery改input type的屬性?

看板Ajax作者 (stuffy)時間16年前 (2009/08/29 13:42), 編輯推噓1(100)
留言1則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《daidos (JAson)》之銘言: : 請問一下 : 怎麼把 input type的屬性 例如 type="text" 改成 type="button" : 我用 : $(function(){ : $("#aaa").attr("type","button") : }); : 一開始網頁就載入就改屬性 : 可是會出現錯誤:已丟出(throw),例外事件但未被接收(catch) : 用click事件也是一樣 : $(function(){ : $("#bbb").click(function(){ : $("#aaa").attr("type","button") : }); : }); : 錯誤訊息也是一樣 : 請問有辦法解決嗎? 我試的結果一樣 不過我搜到解法了 http://www.mail-archive.com/jquery-en@googlegroups.com/msg31270.html 不要用attr 改用replaceWith $("#aaa").replaceWith("<input type=button id=aaa>"); -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 122.116.40.183

08/29 15:56, , 1F
剛測試可以了!結果是我想要的 感謝你喔!!
08/29 15:56, 1F
文章代碼(AID): #1AcB_AsW (Ajax)
討論串 (同標題文章)
文章代碼(AID): #1AcB_AsW (Ajax)