$('input.metaTitle').filter(function() {
$(this).val('ya');
});
The above code finds all inputs with the metaTitle class.
I can’t seem to update it to only select empty fields. I’ve tried things like:
if(!$('input.metaTitle').val()).filter(function() {
$(this).val('ya');
});
Can someone advise how to limit this to only empty inputs.
thx
Use…
jsFiddle.
…to select them.
I think using
$('input.metaTitle[value=""]')may be flaky asdocument.querySelectorAll()checks the initialvalueattribute I think. It also won’t work if the element doesn’t have avalueattribute.