From a JavaScript program, I would like to be able to tell if Bootstrap considers the current display size to be xs, sm, md, or lg.
This works:
In the HTML write this:
<p class="visible-xs-block xyzzy" data-size="xs"></p>
<p class="visible-sm-block xyzzy" data-size="sm"></p>
<p class="visible-md-block xyzzy" data-size="md"></p>
<p class="visible-lg-block xyzzy" data-size="lg"></p>
Then in JavaScript (with JQuery), this expression
$('.xyzzy:visible').attr('data-size')
returns either xs, sm, md, or lg.
This works, but it seems to me to be a rather clumsy way of doing it.
Is there a simpler way?