Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to append variable content inside div with jquery? [closed]

i have some content stored inside a variable and i want to append that content String inside a html div.

This is the script code:

 if ( $( "#eroare" ).val()!="") {
    alert("Error 2" + $( "#eroare" ).val());
    var aux = $( "#eroare" ).val();
    alert("aux="+aux);
    $( "#errorSuccess" ).html( "<b>" + aux + "</b>"); //this is not working
}

And this is the html:

<div id="errorSuccess" >ceva</div>
<div><input type="hidden" id="eroare" value="${sessionScope.errmsg}" /></div>
like image 807
Razvan N Avatar asked Dec 26 '22 16:12

Razvan N


1 Answers

$("#errorSuccess").append("<b>" + aux + "</b>");

or, if you want to be at the beginning of the #errorSuccess content, you need to replace append with prepend

like image 93
n1kkou Avatar answered Dec 28 '22 07:12

n1kkou