var contentofsel=$("#"+a).html().trim();
alert (contentofsel);
$('#temstoredivid').append(
"<div class="maincover" id="maincov1">" +
" <div class="subcover" id="subcover1"> </div>" +
" <div class="forclose" id="forcloseid1"> </div>" +
"</div>");
$('#temstoredivid .maincov1').html(contentofsel);
我需要在div class subcover和id =“subcover1”中打印contentofsel的值。我已经尝试了上面的代码但没有工作。先生,请帮帮我。
答案 0 :(得分:2)
您的字符串文字未正确包含
var contentofsel = $("#" + a).html().trim();
alert(contentofsel);
var $el = $('<div class="maincover" id="maincov1">' +
' <div class="subcover" id="subcover1 "></div>' +
' <div class="forclose" id="forcloseid1"></div>' +
'</div>').appendTo('#temstoredivid');
//but since you are going to override the contents of .maincover element why are you adding 2 div's inside it in the above segment
$el.html(contentofsel);