Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/89.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在单击超链接时动态显示文本区域_Javascript_Jquery_Html - Fatal编程技术网

Javascript 如何在单击超链接时动态显示文本区域

Javascript 如何在单击超链接时动态显示文本区域,javascript,jquery,html,Javascript,Jquery,Html,当我点击超链接时,我想在一个div中动态显示文本区域。请帮忙。谢谢 <div class="fright clr7" style="padding-top:10px;"><a href="">Reply</a></div> <textarea name="motivo" rows="25" cols="50" style="height:100%; display:none; width: 100%" ></textarea&g

当我点击超链接时,我想在一个div中动态显示文本区域。请帮忙。谢谢

<div class="fright clr7" style="padding-top:10px;"><a href="">Reply</a></div>

<textarea name="motivo" rows="25" cols="50" style="height:100%; display:none; width: 100%" ></textarea>

类似

$('a[href*="Reply"]').click(function(){
  // update this selector
   $('textarea[name='motivo']').show();
}); 

和jquery代码:

<script type="text/javascript">

$('a.reply').click(function(){

$(this).closest('textarea').show();

return false;

});

</script>

$('a.reply')。单击(函数(){
$(this).closest('textarea').show();
返回false;
});
您可以执行以下操作:

$("a").on("click", function() {
    event.preventDefault();
    if ($(".fright").find("textarea").length == 0) {
        $(".fright").append('<textarea name="test" id="test"></textarea>');
    }
});
$("a").on("click", function() {
    event.preventDefault();
    $("textarea[name='motivo']").show();
});
这是一个有效的演示:


$('.fright a').click(function() {
    $('.textarea').fadeIn(500);
     return false;
});
函数show() { document.getElementbyId(“text”).innerHTML=“此处的任何内容”; }
试试这个:

$("div.fright a").on("click", function(e) {
    e.preventDefault();
    if($(this).parent("div.fright").find("textarea").length==0)
    $(this).parent("div.fright").append('<textarea name="test" id="test"></textarea>');
});
$(“div.fright a”)。在(“单击”,功能(e){
e、 预防默认值();
if($(this.parent(“div.fright”).find(“textarea”).length==0)
$(本)。母公司(“div.fright”)。追加(“”);
});

试试这种方法

<div class="fright clr7" style="padding-top:10px;"><a href="">Reply</a>
</div>

<textarea name="motivo" rows="25" cols="50" style="height:100%; display:none; width: 100%" ></textarea>
$('.fright a').click(function() {
    $('.textarea').fadeIn(500);
     return false;
});
我想你需要这个 我使用了jquery

<script>
 $("#Test").click(function() {
  $("#TestDiv").html("<textarea rows='4'></textarea>");
 });
</script>


<div class="fright clr7" id="TestDiv" style="padding-top:10px;"><a href="" id="Test">Reply</a></div>

$(“#测试”)。单击(函数(){
$(“#TestDiv”).html(“”);
});

函数showtext()

{

document.getElementById('text_a').style.display='block';

}

您可以尝试以下方法:

$('.fright a').click(function() {
    $('.textarea').fadeIn(500);
     return false;
});

祝您好运…

您可以在单击时创建textarea并将其附加到DIV中,每当用户单击链接时,它都将可用

<div class="fright clr7" style="padding-top:10px;"><a href="">Reply</a></div>

$(function(){
      $('.fright').on('click', 'a', function(e){
        e.preventDefault();
      $('<textarea />', {
          cols: 50,
          rows: 25,
          name: 'motivo',
          class: 'motivo-text'
      }).appendTo('.fright');
});

$(函数(){
$('fright')。在('click','a',函数(e)上{
e、 预防默认值();
$('', {
科尔斯:50,
行:25,
名称:“motivo”,
类:“motivo文本”
}).appendTo('fright');
});

文本区域在哪里..?单击标记可以在jquery中使用隐藏和显示。它位于同一页面上
<div class="fright clr7" style="padding-top:10px;"><a href="">Reply</a></div>

$(function(){
      $('.fright').on('click', 'a', function(e){
        e.preventDefault();
      $('<textarea />', {
          cols: 50,
          rows: 25,
          name: 'motivo',
          class: 'motivo-text'
      }).appendTo('.fright');
});