del_id = $('.button').attr('rel');
alert(del_id)
PHP:
while ($row=mysqli_fetch_assoc($rs)) {
?>
<div class="itemsin" >
<span data-toggle="confirmation" rel="<?php echo $row['id']?>" class="button" id="rmlb">Click to Remove </span>
</div>
<?php
}
}
?>
I tried this but it's alerting only the first value out printed by loop please give me a suggestion
First of all, please post corrected and formatted code in future.
Here is what you need:
Collected all PHP output data in an JS array or object
Create a loop in JS to print all array values.
You need to be carefull with alerting each value because it will give a you a popup box for each array item and the annoying popup will never finish. I suggest outpoint them in console to see the result.
Your JS Code:
del_id = document.querySelectorAll (".button");
for(var i = 0; i < del_id.length; i++){
attrValue = $(this).attr('rel');
console.log(attrValue);
//You can also alert it if you wish to:
//alert(attrValue);
}