jQuery基本插件

jQuery基本插件,jquery,plugins,Jquery,Plugins,我想为一个特定的类签入我的插件 $.fn.Required = function(){ return this.each(function(){ if($(this).hasClass("required")){ $(this).after("*required"); alert("test"); } }); 正如您所看到的,当对象有类“required”时,我尝试将“*required”放在对象后面 如果你有任何解决方案,你可以免

我想为一个特定的类签入我的插件

    $.fn.Required = function(){

    return this.each(function(){

    if($(this).hasClass("required")){
    $(this).after("*required");
    alert("test");

    }
    });
正如您所看到的,当对象有类“required”时,我尝试将“*required”放在对象后面

如果你有任何解决方案,你可以免费发布! -thnx用于阅读-

试试这个

$.fn.Required = function(){ 
    return this.each(function(){
        if($(this).hasClass("required")){
            $(this).after("<label>*required</label>");
            alert("test");
        }
    });
};
$.fn.Required=function(){
返回此值。每个(函数(){
if($(this).hasClass(“必需”)){
$(此)。在(“*必需”)之后;
警报(“测试”);
}
});
};
试试这个

$.fn.Required = function(){ 
    return this.each(function(){
        if($(this).hasClass("required")){
            $(this).after("<label>*required</label>");
            alert("test");
        }
    });
};
$.fn.Required=function(){
返回此值。每个(函数(){
if($(this).hasClass(“必需”)){
$(此)。在(“*必需”)之后;
警报(“测试”);
}
});
};

你的
html
将对我们有更多帮助。你是对的,我以为我上的课是对的,但我没有!你的
html
将对我们有更大的帮助。你是对的,我以为我上的课是对的,但我没有!