jQuery Show/Hide Div -
i'm using show/hide div expander, working fine, however, html entities aren't being outputted.
$(document).ready(function() { $('.slickbox').hide(); $("#slick-toggle").toggle(function() { $(this).text("▲ see less"); $('.slickbox').slidetoggle(500); }, function() { $(this).text("see more ▼"); $('.slickbox').slidetoggle(500); }); }); instead of showing or down arrow entities, outputs
▼ how can make it'll output entities?
.text conversion "text" "html" itself.
from the documentation:
we need aware method escapes string provided necessary render correctly in html. so, calls dom method .createtextnode(), replaces special characters html entity equivalents (such < <).
so text being converted &#9650; , being rendered, point-of-view, verbatim.
you can encode literal directly string (noting javascript \u expects hex, not decimal):
$(this).text("\u25b2 see less"); if want use html entities:
$(this).html("▲ see less"); see this jsfiddle.net snippet shows:
- your approach
- a valid approach encoding literal directly javascript string
- the approach
.html.
Comments
Post a Comment