javascript - jquery script runs only if page refresh -
i have button folowing code
<button type="button" class="btn btn-success btn-xs vote up" id="76" name="up"><span class="glyphicon glyphicon-thumbs-up"></span> bueno</button>
the button not work unless reload page, , dont know why. ideas? jquery code @ origin of body
jquery
<script type="text/javascript"> $(function() { $(".vote").click(function() { var id = $(this).attr("id"); var name = $(this).attr("name"); var datastring = 'id='+ id ; var parent = $(this); var _this = this; if(name=='up') { $(this).fadein(600).html('<span class="glyphicon glyphicon-ok"></span>'); $.ajax({ type: "post", url: "up_vote.php", data: datastring, cache: false, success: function(html) { parent.html(html); $( _this ).remove(); $( ".escondido" ).css( "display", "block" ); } }); homecoming false; }); }); </script>
if jquery code @ origin of code (before html) state, dom not have been created yet. seek moving jquery code bottom of body (after html).
javascript jquery
No comments:
Post a Comment