Is it possible to select buttons using the text property in jQuery?
I was trying like:
$.each(data, function(index, element){
if(element.table_aval == 0)
{
var elmt = element.table_no;
$('#table button[text='+elmt+']').css('color','red');
}
});
Is this possible?
The :contains selector allows you to select elements containing a specific string.
$(document).ready(function() {
$('button:contains("Text")').css({'color': 'red'})
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button>Text</button>
<button>Something Different</button>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With