jQuery将文本附加到现有的with复选框

jQuery将文本附加到现有的with复选框,jquery,Jquery,所以我有一个复选框和文本区域 <input type="checkbox" value="" class="responsive" checked="checked"> Responsive?<br /> <textarea cols="40" rows="5" placeholder="<?php echo $entry_code; ?>" id="input-code" class="form-control afftextie"><di

所以我有一个复选框和文本区域

<input type="checkbox" value="" class="responsive" checked="checked"> Responsive?<br />
<textarea cols="40" rows="5" placeholder="<?php echo $entry_code; ?>" id="input-code" class="form-control afftextie"><div class="intrinsic-container"><iframe src="content.php" style="overflow: hidden;border:none;width:1000px;height:400px" scrolling="no""></iframe></div></textarea>
Responsive?
我编辑你的小提琴

你必须稍微修改一下你的代码。首先,您可以使用
.val()
而不是
.append()
访问
文本区的内部。那么你需要一个检查过的条件

var $input = $( '.afftextie' ).text();
$( ".responsive" ).change(function() {

    if ( $(this).prop("checked") ) {

        $( '.afftextie' ).append($input+'<style>.intrinsic-container{position:relative;overflow:hidden;min-height:400px;margin-bottom:10px}.intrinsic-container iframe{position:absolute;top:0;left:0;width:100%;height:100%;border:none}@media (max-width:990px){.intrinsic-container{min-height:1151px}}@media (max-width:510px){.intrinsic-container{min-height:1570px}}</style><div class="intrinsic-container"><iframe src="content.php" style="overflow: hidden;border:none;width:1000px;height:400px" scrolling="no""></iframe></div>').text()

    } else {

        $( '.afftextie' ).html("");

    }
}).change();
var$input=$('.afftextie').text();
$(“.responsive”).change(函数(){
如果($(this).prop(“选中”)){

$('.afftextie').append($input+')。内部容器{position:relative;overflow:hidden;最小高度:400px;margin bottom:10px}。内部容器iframe{position:absolute;top:0;left:0;width:100%;height:100%;border:none}@media(max width:990px){。内部容器{min height:1151px}}@media(max width:510px){。内部容器{min height:1570px}
appennd
不是一个函数
scrolling=“否”"
是无效的标记请在答案中发布代码。然后它可以在文本区域和单击样式时获得+1 iframe需要added@Grasper,ebilgin为您提供了足够的信息,使您能够完全按照要求解决问题。您可能没有提供足够的信息。您无法在textarea中添加iframe。textarea是用于m control您可以插入文本,而不是HTML。其次,将css添加到iframe是您必须问的另一个问题。请编辑您的问题。我会编辑小提琴。我认为它更接近您的要求。
var $input = $( '.afftextie' ).text();
$( ".responsive" ).change(function() {

    if ( $(this).prop("checked") ) {

        $( '.afftextie' ).append($input+'<style>.intrinsic-container{position:relative;overflow:hidden;min-height:400px;margin-bottom:10px}.intrinsic-container iframe{position:absolute;top:0;left:0;width:100%;height:100%;border:none}@media (max-width:990px){.intrinsic-container{min-height:1151px}}@media (max-width:510px){.intrinsic-container{min-height:1570px}}</style><div class="intrinsic-container"><iframe src="content.php" style="overflow: hidden;border:none;width:1000px;height:400px" scrolling="no""></iframe></div>').text()

    } else {

        $( '.afftextie' ).html("");

    }
}).change();