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 &amp;#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("&#9650; see less"); 

see this jsfiddle.net snippet shows:

  • your approach
  • a valid approach encoding literal directly javascript string
  • the approach .html.

Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -