I have this code:
PHP:
<?php if ($row['Status'] == 'In Process'):?>
<span class="badge" style="background-color:#67A6DF">In Process</span>
<?php endif; ?>
<?php if ($row['Status'] == 'Test'): ?>
<span class="badge" style="background-color:#FCB529">In Test</span>
<?php endif;?>
<?php if ($row['Status'] == 'Approved'):?>
<span class="badge" style="background-color:#43A995">Approved</span>
<?php endif;?>
jQuery:
$(document).ready(function() {
$('.approved').on('click', function(){
var process = $('.badge').html();
alert(process);
});//Onclick
});
Button:
<a href="javascript:void(0);" class="flex-icon approved" data-toggle="tooltip" data-placement="top" title="approve" data="5"><i class="fa fa-check-square-o fa-2x" aria-hidden="true"></i></a>
And I'm trying to get the text of the <span>
tags, but every time I try to get it, it alerts the same text.
How do I get the value of different <span>
tags in the same jQuery function?
Try to change the jquery as below
$(document).ready(function() {
$('.approved').on('click', function(){
$('span.badge').each(function() {
alert( $(this).html());
});
});//Onclick
});
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.