[英]How to find the div inside the texarea content and replace the style using jquery
I have the textarea element below : 我在下面有textarea元素:
<table><tr><td><textarea class="text_popup" id="script" ><script src="script.js"></script><script>$(document).ready(function(){$(".iframe").colorbox({iframe:true, width:"300px", height:"500px",});});</script><a class="main"><div id="new_text_val">test</div></a></textarea></td></tr></table>
$.ajax({
type: 'POST',
url: "newpage.php",
async: true,
data: 'name=' + name +'&age=' + age ,
cache: false,
success: function(data){
// response data
}
});
after the ajax success <div id="new_text_val">test</div>
should be replaced to success response data ajax成功
<div id="new_text_val">test</div>
应替换为成功响应数据
final replace looks like below 最终替换如下所示
<table><tr><td><textarea class="text_popup" id="script" ><script src="script.js"></script><script>$(document).ready(function(){$(".iframe").colorbox({iframe:true, width:"300px", height:"500px",});});</script><a class="main">ajax succes resonse data </a></textarea></td></tr></table>
First put the new element after the current element and then remove the current element. 首先将新元素放在当前元素之后,然后删除当前元素。
$('#new_text_val')
.after('<div class="inside_text"><div><img src=image.png></div></div>')
.remove();
Try this in your success function: 在成功功能中尝试以下操作:
$('#new_text_val').parent().html(" <div class='inside_text'><div><img src=image.png></div></div> " );
It is very hard to read your question btw. 很难阅读您的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.