如何在jquery中添加id? [英] How to add id in jquery?

查看:93
本文介绍了如何在jquery中添加id?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在jquery中创建了一个对话框。并且有一个名为保存的按钮。我需要为这个保存按钮添加一个id。我怎样才能在jquery中实现这个目标。这是我的代码

I have created one dialog box in jquery. and there is one button called 'save'. I need to add one id to this save buttton. How can I achive in this in jquery. This is my code

$(function() {
    $( "#dialog" ).dialog({

         height: 400,
      width: 650,
      modal: true,
      buttons: {

        Save: function() {
          dialog.dialog( "close" );
        }
      },
      close: function() {
        form[ 0 ].reset();
        allFields.removeClass( "ui-state-error" );
      }

    });
});


推荐答案

使用 $(按钮)。attr(id,testid);

这篇关于如何在jquery中添加id?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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