Link to home
Start Free TrialLog in
Avatar of elepil
elepil

asked on

jQuery question

I don't understand something.

$("#myDiv").text("<b>Boo</b>");

<div id="myDiv"></div>

Open in new window


The browser will actually display '<b>Boo</b>' without boldfacing the word 'Boo'. When I examine the source through the browser's debugger (e.g. webkit), the text doesn't show the output as using HTML entities like &gt; or &lt;, nor are any of the characters escaped in any way.

Can someone please explain to me what's happening here?
SOLUTION
Avatar of Brian Tao
Brian Tao
Flag of Taiwan, Province of China image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of elepil
elepil

ASKER

Taoyipai, thanks for responding. I am aware about html(). My question is how come the text(string) output, despite obviously being escaped, is not showing in View Source or through the browser debugger.
It won't show in view source because that is the rendered HTML at load, anything you add is in the browsers DOM

Jquery will html encode the < and > etc to their equivalent (&gt; or &lt;) but when you view it the debugger you will see the actual < >
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of elepil

ASKER

Thanks for all your help!