I wrote lots of code following XHTML rules, so I have things like this:
<input type="text" name="Field1" disabled="disabled">
<input type="text" name="Field2" readonly="readonly">
Thanks God, HTML5 went back to the old days where we could just do this:
<input type="text" name="Field1" disabled>
<input type="text" name="Field2" readonly>
However, how can I use jQuery to set or unset these boolean attributes? I always used .attr("readonly", "readonly")
, but it generates the older XHTML syntax. I want my code to be the HTML5 way, with just "readonly", or just "disabled".
By the way, using .prop()
won't work for me, I need to really change the attributes on my markup, because I have CSS rules depending on these attributes. Any ideas?
Thanks in advance.