escape less / greater than javascript

前端 未结 2 1328
Happy的楠姐
Happy的楠姐 2021-01-13 15:31

I\'m having a problem trying to escape some code... Basically, I want to escape \"<\" and \">\" but I want them to APPEAR in my #output div as \"<\" and \">\". Current

2条回答
  •  逝去的感伤
    2021-01-13 15:58

    Try this:

    var textval = $("#textarea").val();
    $("#output").text(textval);      
    

    jQuery offers two methods - $.text() and $.html() where the method names speak for themselves :)

提交回复
热议问题