onclick only works once
onclick only works once
This is my HTML
- <div id="divlisting_status<?php echo $row['sell_detail_id']; ?>">
- <?php
-
- if($row['listing_status'] == "0")
- {
- ?>
- <img id="approve" src="https://pencopyediting.com/images/not_approved.png" sell_detail_id ="<?php echo $row['sell_detail_id']; ?>" listing_status="not_approved" /> <?php echo "<span class='status_list'>Not Approved</span>";
- ?>
- <?php
- }
- else
- {
- ?>
- <img id="approve" src="https://pencopyediting.com/images/approved.png" sell_detail_id = "<?php echo $row['sell_detail_id']; ?>" listing_status="approved" /> <?php echo "<span class='status_list'>Approved</span>";
- ?>
- <?php
- }
-
-
- ?>
- </div>
This is my ONCLICK on the div
- $('div[id^="divlisting_status"]').click(function() {
- alert("aa");
- url = "https://pencopyediting.com/change_listing_status/change_status.php?sell_detail_id="+ $(this).children('img').first().attr('sell_detail_id')+"&listing_status="+ $(this).children('img').first().attr('listing_status');
-
- if(window.XMLHttpRequest) {
- http=new XMLHttpRequest();
- }
- else if(window.ActiveXObject) {
- http=new ActiveXObject("Microsoft.XMLHTTP");
- }
-
- http.open("GET", url , true);
-
- http.onreadystatechange= mediumProcess;
-
- http.send(null);
- })
This is the code for changing the image
- if(ajax_reply_status == 'approved')
- {
- alert("Selling list is approved now");
- $("#" + show_statusbyid).replaceWith( '<img id="approve" src="https://pencopyediting.com/images/approved.png" sell_detail_id="'+ajax_reply_id+'" listing_status="'+ajax_reply_status+'" /><span class="status_list">Approved</span>');
- }
- else
- {
- alert("Selling list is not approved now");
- alert(show_statusbyid);
- $("#" + show_statusbyid).replaceWith( '<img id="approve" src="https://pencopyediting.com/images/not_approved.png" sell_detail_id="'+ajax_reply_id+'" listing_status="'+ajax_reply_status+'" /><span class="status_list">Not Approved</span>');
-
- }
Once the image has changed the onclick isn't being called and I have no idea how to get it working. The click is on the div not the image and I am only changing the image
Thanks