When injecting text inside a div, I need to insert a url safely in javascript using jquery

By : mrblah
Source: Stackoverflow.com
Question!

Using jquery I am doing something like:

$("#someId").append("this is some text, go here.");

How can I insert a url like this safely? Is there an easier way to escape all those characters that will cause js to break?

By : mrblah


Answers

Try using the html function, jquery docs

I'm no expert but something like this should work

$("#someId").html("
By : Simon Fox


Unless I'm mistaken by what you are asking, you could do something like

link = $('
By : theIV


I think escape should do it:

$("#someId").append(escape('this is some text, go here'));
By : karim79


This video can help you solving your question :)
By: admin