मुझे अपने ईवेंट हैंडलर को आग लगने में परेशानी हो रही है। मैं जेएसओएन को पेज में नीचे कॉल कर रहा हूं। मैं फिर अपने द्वारा बनाए गए बटनों में से एक पर क्लिक करने में सक्षम होना चाहता हूं जो 'हैलो वहां' अलर्ट निष्पादित करेगा। यह पृष्ठ पर हर दूसरे तत्व के साथ काम करता है, लेकिन <button>
नहीं।jQuery पर काम नहीं कर रहा
क्या कोई मदद कर सकता है?
test.js
$(document).ready(function() {
$.getJSON('/api/v1/recipe/?format=json', function(data) {
$.each(data.objects, function(i, recipe) {
$('table#recipes').append('<tr><td>' + recipe.title + '</td><td>' + recipe.ingredients + '</td><td>' + recipe.method + '</td><td><button class="btn" type="button" id="rmv">remove</button></td></tr>');
});
});
$('rmv').on('click', function() {
alert('hello there!');
});
});
recipe.html
{% extends 'base.html' %}
{% block content %}
<div class="container-fluid">
<div class="row-fluid">
<div class="span6">
<form action='' method="post">{% csrf_token %}
{{ form.as_p }}
<input type="submit" value="go baby!">
</form>
</div>
<div class="span6">
<table class="table table-striped table-bordered" id="recipes">
<tr>
<th>Title</th>
<th>Ingredients</th>
<th>Method</th>
<th>Remove</th>
</tr>
</table>
</div>
</div>
</div>
{% block recipes %}{% endblock recipes %}
{% endblock content %}
'RMV
बदलें = # rmv' - –
ajax अतुल्यकालिक है। –