My html fragment goes something like
<button data-file="day">Day</button>
<button data-file="night">Night</button>
and I'm trying to do the following in Jquery
var $button = $('button');
$button.data('file' , 'day').attr('disabled', 'disabled');
So make jQuery objects of all buttons then disable the button with data attribute day
You need to use the attribute selector and need to use .prop() to set the disabled state
var $button = $('button[data-file="day"]');
$button.prop('disabled' , true);
Update
var $button = $('button');
$button.filter('[data-file="day"]').prop('disabled' , true);
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