For example, in this HTML:
<div class="el">   ;  ;  ;  ;HasNbsp</div>
<div class="el">NoNbsp</div>
I would like to select the element that has " " in it.
I tried this:
$("div.el").html().contains(" ")
But it's not working.
How can I correctly target the element that contains a non-breaking space?
Note: I need to keep the non-breaking space, so removing it isn't an option.
Use \u00a0
in your selector instead of
So in your case, you want this:
$("div.el").html().contains("\u00a0")
Here's a CodePen with some more example code:
https://codepen.io/anon/pen/QJpPJV
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