-1

I have a table where users that are awaiting approval are listed, an administrator can click on a table row and once he did so the information of the user will be displayed below in a box, I've did this before but I did a mistake, I used ID on the row and I was doing a loop to show all the rows, well, ID can be used only once so it worked only with the first row, I now changed the ID of the row to a CLASS and my jQuery isn't working anymore, the box is not showing at the bottom along with the user info.

Here is the table row:

<tr data-id="<?php echo $datum['ID']; ?>" class="rowID" href="#">

And here is my script:

$(".rowID").click(function() {
    var User = $("#userID");
    var Box = $("#userBox");

    Box.show();
    $("#userBox").animate({
        maxHeight: '+=1000px'
    }, 1000);

    $("html, body").animate({
        scrollTop: $(document).height()
    }, 1000);

    $("#thisHR").show();
    $("#thisHR").animate({
        maxWidth: '+=1000px'
    }, 1000);

});

EDIT

I've tried this $(document).on('click','body.rowID',function(){ but it still doesn't work.

  • 2
    Are there any errors in the console . Can you provide a snippet or a fiddle for the issue. – Dan Philip Bejoy May 02 '17 at 14:08
  • @DanPhilip only errors that I see are 404 for fastclick.js, slimscroll.min.js, datepicker, daterangepicker which I don't think they have anything to do with this. – Mister Knuckles May 03 '17 at 17:01
  • What's this in the middle of your code `p b`? – j08691 May 03 '17 at 17:22
  • @j08691 I noticed that earlier too, removed that must be a typo, still not working – Mister Knuckles May 03 '17 at 17:27
  • Welcome to Stack Overflow! [What does your step debugger tell you?](http://stackoverflow.com/questions/25385173/what-is-a-debugger-and-how-can-it-help-me-diagnose-problems) –  May 03 '17 at 17:27
  • `.on('click','body.rowID',` would not work because you want to listen to a click event on a `tr` element and not one a `body` with the class `.rowID`. It has to be `.on('click','.rowID',` or `.on('click','tr.rowID',` – t.niese May 03 '17 at 17:27
  • Welcome to Stack Overflow! Please read [How do I ask a good question?](http://stackoverflow.com/help/how-to-ask) before attempting to ask more questions. –  May 03 '17 at 17:28
  • @t.niese I've tried that too, still not working. – Mister Knuckles May 03 '17 at 17:30
  • @JarrodRoberson Can you also tell me what is wrong at my question... I can't seem to solve my issue by searching google, all of them have different issues and my code was working perfectly with #id, .class bugged it... – Mister Knuckles May 03 '17 at 17:31

2 Answers2

0

I solved my issue, I had to use " instead of `

$(document).on("click",".rowID",function(){

not

$(document).on('click','.rowID',function(){
-1
  1. If tr is coming dynamically u can try below click event.

    $(document).on('click','.rowID', function(){ //action });

  2. If u want to take ID from that class click event u can try below code.

    $('.rowID').on('click', function(){ var id = $(this).attr('id'); console.log(id); });