I have the following code:
<p>
To
<br>
{customerDetails}
</p>
I tried by following but it gave an error.
Jerry doc = Jerry.jerry(FileUtil.readString(file));
doc.$("#customerDetails").text(ci.name + "<BR/>" + ci.addr1);
Here the text which will be replaced by {customerDetails} should be independent, thats why i do not want to take any help of tags. If i give any tag for {customerDetails}, "To" will be distrubed.
I want to replace the "{customerDetails}" with some text without take any help of html tags or css classes and id's. Is it possible?
First of all, this is not a javascript question, but Java question. It's about Jodd Jerry, parsing library in Java that looks very similar to jQuery. So all jsfiddle solutions here does not help, and I believe some negative scores on this question are not ok.
Anyway, the @Archer solution is one that can you give a good direction. Here is the java version of the same:
Jerry still does not have
html(function)
type of method implemented (it's on todo), so you have to useeach
explicitly.Note that you can not search for
#customerDetails
as you don't have any DOM element with this ID. What you could do instead, is to have an empty placeholderdiv
or aspan
like this:and then you would be able to do something like you wrote in the question.
Anyway, I would try to solve this in a different way, if possible. If you already have a marker and HTML content, can you simply replace it without parsing?