jQuery append()不会追加到我的元素 [英] jQuery append() won't append to my element

查看:317
本文介绍了jQuery append()不会追加到我的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于某些原因,jQuery append()不适用于以下我的任何代码示例.看到我做错了吗?我试图禁用提交"按钮,并附加一些文字正在处理...".

jQuery append() doesn't work with either of my code examples below for some reason. Do you see what I'm doing wrong? I am trying to disable the submit button and append some text that says "Processing...".

示例代码1:

$( "input[type='submit']" ).click( function()
{
    $( this ).attr( "disabled", "disabled" );
    $( this ).parents( "form" ).submit();
    $( this ).append( " Processing..." ); // no worky
    //$( "input[type='submit']" ).append( " Processing..." ); // no worky
});

示例代码2:

$( "form" ).submit( function()
{
    //$( "#submit_button" ).append( " Processing..." ); // no worky
    $( this ).find( "input[type='submit']" ).prop( "disabled", "disabled" );
    $( "#submit_button" ).append( " Processing..." ); // no worky
});

推荐答案

尝试一下

$( this ).after( " Processing..." );

$( this ).append( " Processing..." );实际上像<input type="submit">processing</input>这样在输入标签内附加文本,它不会显示在前端,但是如果在其后使用,它将在输入元素后附加文本

$( this ).append( " Processing..." ); actually append the text inside the input tag like this <input type="submit">processing</input> and it will not display in front end but if you use after it will append the text just after the input element

这篇关于jQuery append()不会追加到我的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆