F3jko
F3jko

Reputation: 41

Change only specific href name on hover jQuery

<td><a href="Wizyty-proces.php?status=<?php echo $row['idwizyty']; ?>" class="status">
 <?php echo $row['status'];?></a></td>
var elem = $('.status'), orig = elem.text();
    elem.hover(
    function() { $(this).text('End'); },
    function() { $(this).text(orig); }
);

Is there a way to change the href name only when the name of href is 'Waiting'? I'm looping through my database and $row['status'] is either 'Waiting' or 'Done'. I want to change name of href on hover to 'End' only when it equals 'Waiting'.

Upvotes: 0

Views: 25

Answers (1)

jorgedjr21
jorgedjr21

Reputation: 111

You can set a property in your link that helps you get the links you want, something like:

<a href="Wizyty-proces.php?status=<?php echo $row['idwizyty']; ?>" data-status="<?php echo $row['idwizyty']; ?>" class="status">Link </a>

And in your js/jquery script, you can get the elements with the specified status with something like this:

var element = $('.status').filter('[data-status="waiting"]')

Hope this helps you.

Upvotes: 1

Related Questions