Info's: I have some javascript code that i will show below, who i'm having problem with quotes.
html = [];
style = 'class=odd';
html.push('<li '+style+' onclick=SelectItem("'+ele.id+'","'+idItem+'","'+dsItem+'","'+qtItem+'"); >'+id+' - '+$iObjItensListaVenda.result.ds_item[i]+'</li>');
I have strings that i get from a JSON Object, as you see above.
Problem: But when i'm trying to place it as a Function Parameter on the onClick
event of the <li>
element, my resulting html <li>
element becomes totally unformatted like that:
<li natural,"150");="" white="" american="" onclick="SelectItem("descItem1","2",TELHA" class="odd">00002 - TELHA AMERICAN WHITE NATURAL</li>
What do i want: i need a solution like a function, maybe already exists in jQuery, to Quote my String. Like a QuoteStr("s t r i n g");
to become ""s t r i n g""
.
Maybe you're complaining about:
- The variable
ele
is a html<input>
element. - The variable
idItem
contains only numbers, they come from a JSON Object. - The variable
dsItem
its a string containing Item Description, it comes from the JSON Object too. - The variable
qtItem
contains only numbers, it is the quantity of the items, it comes from the JSON too.