开发者

Escape encode all character within pre tags

开发者 https://www.devze.com 2023-03-09 14:10 出处:网络
I am looking to escape all code within the <pre> tags so I can display it to the browser. Here is what I am trying to do...

I am looking to escape all code within the <pre> tags so I can display it to the browser.

Here is what I am trying to do...

<pre><code>
  Code below
   <?php
     if ( $is_iphone ) { ?>
    <meta name="viewport" content="width=320; initial-scale=0.9; maximum-scale=1.0; user-scalable=0;" />
   <?php } ?>
</pre></code> 

I am looking to use jQuery to do this. Is there a function?

So the output would be.

<pre><code>
  Code below
    &lt;?php
      if ( $is_iphone ) { ?&gt;
        &lt;meta name开发者_JAVA百科="viewport" content="width=320; initial-scale=0.9; maximum-scale=1.0; user-scalable=0;" /&gt;
    &lt;?php } ?&gt; 
</pre></code>

Can you do this with jQuery?

Here is my code.

<script type="text/javascript"> 
    $(function() 
    {

    $("#teatarea").keyup(function() 
    {
    var textarea=$(this).val();

    // I can change this function to text instead of HTML but I need the <pre> tags to stay as HTML to display to the browser???

    $(".addesc1").html(textarea);

    return false;
    });

    });
</script> `

HTML:

<div id="dis" class="addesc1">
  Description Line 1
</div> 


as you have asked for the textarea with php i have done it here is the demo http://fiddle.jshell.net/3y4qA/1/

you cannot retrive php with jquery as you have asked but you can try to post it via ajax and get the value

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号