web developer๐Ÿ‘ฉ๐Ÿป‍๐Ÿ’ป

[jQuery] ๋™์  ์ถ”๊ฐ€๋œ append์— click event ์ฒ˜๋ฆฌ ๋ณธ๋ฌธ

js

[jQuery] ๋™์  ์ถ”๊ฐ€๋œ append์— click event ์ฒ˜๋ฆฌ

natrue 2021. 10. 26. 17:15
728x90

append ํ•œ button์— ํด๋ฆญ์ด๋ฒคํŠธ๋ฅผ ์ฃผ๋‹ˆ ์ด๋Ÿฐ ์˜ค๋ฅ˜ ๋ฉ”์‹œ๊ฐ€ ์ถœ๋ ฅ. 

(index):1 Uncaught ReferenceError: ํ•จ์ˆ˜๋ช… is not defined
    at HTMLButtonElement.onclick ((index):1)

์›์ธ : ๋™์ ์œผ๋กœ ์ถ”๊ฐ€๋œ ํƒœ๊ทธ๋Š” ์ด๋ฒคํŠธ๊ฐ€ ๋™์ž‘๋˜์ง€ ์•Š์Œ. = ๋กœ๋“œ๋˜์—ˆ์„ ๋•Œ ์กด์žฌํ•˜์ง€ ์•Š๋Š” ํƒœ๊ทธ์— ๋Œ€ํ•ด์„œ๋Š” ์ด๋ฒคํŠธ๋ฅผ ๊ฑธ ์ˆ˜ ์—†๋Š” ๊ฒƒ

 $(document).on('click / change  ๋“ฑ๋“ฑ์˜ ์ด๋ฒคํŠธ', '์ด๋ฒคํŠธ ์ ์šฉํ•  ํƒ€๊นƒ ํƒœ๊ทธ', ๋™์ž‘ ํ•จ์ˆ˜(){});

๋˜๋Š” 

$('.๋ถ€๋ชจ ์ด๋ฆ„').on('click', '.๊ฑธ๊ณ  ์‹ถ์€ ๋Œ€์ƒ', function() {
 ๋„ฃ์„ ์†Œ์Šค;
});

 

 

 

์ถœ์ฒ˜ : https://stackoverflow.com/questions/15420558/jquery-click-event-not-working-after-append-method

 

Jquery click event not working after append method

So I have this button which adds a new row to the table, however my problem is that it does not listen to the .new_participant_form click event anymore after the append method has taken place. htt...

stackoverflow.com