Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/70.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/css/32.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sql-server-2005/2.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
如何在Jquery错误放置中应用负边距或类? $(“#frmNewList”)。验证({ 规则:{ 价格:{ 要求:正确, 数字:对 } }, 信息:{ 价格:{ 必填:“请输入价格”, 编号:“请仅输入金额” } }, 错误位置:函数(f,g){ 如果(g.attr('id')='price') { f、 addClass(“保证金”); f、 css({'margin-left':'-10px!important'}); } }); .margin{左边距:-10px!重要; }_Jquery_Css - Fatal编程技术网

如何在Jquery错误放置中应用负边距或类? $(“#frmNewList”)。验证({ 规则:{ 价格:{ 要求:正确, 数字:对 } }, 信息:{ 价格:{ 必填:“请输入价格”, 编号:“请仅输入金额” } }, 错误位置:函数(f,g){ 如果(g.attr('id')='price') { f、 addClass(“保证金”); f、 css({'margin-left':'-10px!important'}); } }); .margin{左边距:-10px!重要; }

如何在Jquery错误放置中应用负边距或类? $(“#frmNewList”)。验证({ 规则:{ 价格:{ 要求:正确, 数字:对 } }, 信息:{ 价格:{ 必填:“请输入价格”, 编号:“请仅输入金额” } }, 错误位置:函数(f,g){ 如果(g.attr('id')='price') { f、 addClass(“保证金”); f、 css({'margin-left':'-10px!important'}); } }); .margin{左边距:-10px!重要; },jquery,css,Jquery,Css,我有两个问题: 1) 我想应用代码中显示的-10px边距,但它不起作用。 2) 我添加了代码中显示的margin类。 两者都是单独添加的。但两者都不起作用。!重要信息不适用于JQuery css 更改代码 $("#frmNewList").validate({ rules:{ price:{ required: true, number: true

我有两个问题: 1) 我想应用代码中显示的-10px边距,但它不起作用。 2) 我添加了代码中显示的margin类。
两者都是单独添加的。但两者都不起作用。

!重要信息
不适用于JQuery css

更改代码

    $("#frmNewList").validate({
    rules:{
    price:{
                        required: true, 
                        number: true
                          }
          },
    messages: {
    price:{ 
                        required: "Please Enter The Price",
                        number: "Please Enter the amount only"
                         }
              },
    errorPlacement:function(f,g){
             if(g.attr('id')=='price')
              {
                f.addClass('margin');
                f.css({'margin-left':'-10px !important'});
             }

    });
<style>
.margin{margin-left:-10px !important;
}
</style>

演示:

更新:确定您可以使用
margintop

f.css({'margin-left':'-10px'});

演示:

!重要信息
不适用于JQuery css

更改代码

    $("#frmNewList").validate({
    rules:{
    price:{
                        required: true, 
                        number: true
                          }
          },
    messages: {
    price:{ 
                        required: "Please Enter The Price",
                        number: "Please Enter the amount only"
                         }
              },
    errorPlacement:function(f,g){
             if(g.attr('id')=='price')
              {
                f.addClass('margin');
                f.css({'margin-left':'-10px !important'});
             }

    });
<style>
.margin{margin-left:-10px !important;
}
</style>

演示:

更新:确定您可以使用
margintop

f.css({'margin-left':'-10px'});

演示:

什么是错误控制台报告?你确定
typeof f
,是一个jQuery对象?什么是错误控制台报告?你确定
typeof f
,是一个jQuery对象?很好=]尽管@aliasgar vanak注意,你不需要使用
!重要的
,因为它是一个内联样式。它拥有尽可能多的权限已经有了。@MackieeE:谢谢,但有一个问题是我在使用margin\u left后无法应用margin\u top。@Satpal:谢谢,伙计。一个问题是我在使用margin\u left后无法应用类,也无法应用margin\u top。@Satpal:再次感谢,伙计。我写了这个代码,但当我检查元素时,它显示我在margin left中是10px,而不是-10px。并且当我通过inspect元素设置它时,我得到了我的结果。很好=]尽管@aliasgar vanak注意到了这一点,但您不需要使用
!重要的
,因为它是一种内联样式。它已经获得了尽可能多的权限。@MacKeee:谢谢,但有一个问题,我在使用margin\u left后无法应用margin\u top。@Satpal:谢谢老兄。一个问题是,在使用了margin_left之后,我不能应用类,也不能应用margin_top。@SatPal:再次感谢老兄。我写了这个代码,但当我检查元素时,它显示的是margin left中的10px,而不是-10px。当我通过inspect元素设置它时,我得到了我的结果。