[英]get updated changed html from textarea
long time reader first time asker.... 长期读者首次问道...
If I have a textarea with html text in it (I am trying to verify certain elements have an id) and I send that code to a function how do i update that textarea with the new changes? 如果我有一个带有html文本的textarea(我正在尝试验证某些元素是否具有id),并且将该代码发送给一个函数,该如何使用新更改来更新该textarea?
I have tried wrapping it in a div from previous suggestions I read here, but its not showing me the updated html. 我已经尝试将它从之前在这里阅读的先前建议中包装到div中,但它没有显示更新的html。
Here is my fiddle https://jsfiddle.net/gk6yLh77/ 这是我的小提琴https://jsfiddle.net/gk6yLh77/
function runfunc(){
var uniqueIdFind = '<div>'+jQuery('#pages_htmlcode_content').val()+'</div>';var curDateEpochSec='12112';
if(jQuery('#content-wrapper',uniqueIdFind).length==1){
jQuery('#content-wrapper',uniqueIdFind).find('[onclick], [href]').not('link').not('a[nostat],[statproc],a[href="#top"]').each(function(index){
if(!jQuery(this,uniqueIdFind).attr('id')){console.log('id======dd_'+curDateEpochSec+'_'+index);jQuery(this,uniqueIdFind).attr('id','dd_'+curDateEpochSec+'_'+index);}
});
jQuery('#pages_htmlcode_content2').val(uniqueIdFind);
}else{
alert('erros')
}
}
I put a console write in the function and can see the id's being added, but for the life of me I can not figure out how to get those changes. 我在功能中写入了控制台,可以看到ID的添加,但是对于我来说,我一直不知道如何进行这些更改。
here is the sample html to put into the first textarea 这是放入第一个文本区域的示例html
<html lang="en-US">
<head>
</head>
<body id="com">
<div id="top" class="landing-page">
</div>
<div id="content-wrapper">
<div id="content-main">
<a href="dssdfsdf" class="asda">asdasad</a>
</div>
</div>
</body>
</html>
It just spits out the original code :( 它只是吐出原始代码:(
Thanks 谢谢
You neeed to wrap your test element in $()
您需要将测试元素包装在
$()
example: 例:
if(jQuery(uniqueIdFind).find('#content-wrapper').length==1)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.