나는이 html을 데이터베이스의 데이터를 기반으로 동적으로 생성했습니다. 사용자가 라디오 버튼을 클릭 할 때 ajax를 사용하여 웹 서비스를 호출하고 사용자가 선택할 수있는 다른 라디오 버튼 목록을 만들 수 있도록 마법사를 만들려고합니다. 초기 페이지로드는 정상적으로 작동하지만 이벤트 발생과 관련된 문제가있는 동적 라디오 버튼 목록을 만들 때 발생합니다. 이 기능을 사용하려면 문서 또는 특정 div를 다시로드해야합니까?라디오 버튼이 발사되지 않아도 변경됨
이 라디오 버튼 중 하나를 선택하면 "change"이벤트를 트랩하고 싶습니다. 아래의 jQuery는 이벤트를 캡처하지 않습니다. 내가 뭘 잘못하고 있는지에 대한 제안이 있니?
HTML :
<input name="productModel" id="Basic-jacketCustom" type="radio" value="Basic jacket"><label for="Basic-jacketCustom">Basic jacket</label>
<input name="productModel" id="Platinum-jacketCustom" type="radio" value="Platinum jacket"><label for="Platinum-jacketCustom">Platinum jacket</label>
<input name="productModel" id="Platinum-Pro-jacketCustom" type="radio" value="Platinum Pro jacket"><label for="Platinum-Pro-jacketCustom">Platinum Pro jacket</label>
<input name="productModel" id="Riding-jacketCustom" type="radio" value="Riding jacket"><label for="Riding-jacketCustom">Riding jacket</label>
jQuery를 :
$('input[name="productModel"]').change(function() { alert("Event
Fires"); });
작품 : 다음의 예를보십시오 http://jsfiddle.net/yjxs36pq/ 당신의 경고가 어쩌면 같은 줄에있을 필요가 있겠습니까? 동적 HTML 요소를 만들려면 .on jQuery를 사용해야합니다. http://api.jquery.com/on/ – 97ldave