jQuery   发布时间:2022-04-19  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了我是否使用开关或其他方式来简化此操作? jQuery的大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我尝试使用两个开关,如果没有,但我无法让它正常工作.我想不要多次重复自己.

$('div.ui-widget-content').on("click",".date-edit",function () {
            var dateInput = jQuery(this).html("");
            $(".pop-up-Box-date").dialog(dateInput);
        });

        $('div.ui-widget-content').on("click",".radio-edit",function () {
            var radioInput = jQuery(this).html("");
            $(".pop-up-Box-radio").dialog(radioInput);
        });

        $('div.ui-widget-content').on("click",".@R_673_10943@kBox-edit",function () {
            var @R_673_10943@kBoxInput = jQuery(this).html("");
            $(".pop-up-Box-@R_673_10943@kBox").dialog(@R_673_10943@kBoxInput);
        });

        $('div.ui-widget-content').on("click",".dropdown-edit",function () {
            var dropdownInput = jQuery(this).html("");
            $(".pop-up-Box-dropdown").dialog(dropdownInput);
        });

        $('div.ui-widget-content').on("click",".telephone-edit",function () {
            var telephoneInput = jQuery(this).html("");
            $(".pop-up-Box-telephone").dialog(telephoneInput);
        });

        $('div.ui-widget-content').on("click",".button-edit",function () {
            var buttonInput = jQuery(this).html("");
            $(".pop-up-Box-button").dialog(buttonInput);
        });

        $('div.ui-widget-content').on("click",".textarea-edit",function () {
            var textareaInput = jQuery(this).html("");
            $(".pop-up-Box-textarea").dialog(textareaInput);
        });

对此很新,所以如果有更好的方法我不知道,请告诉我.谢谢

这是HTML块之一:

<div class='pop-up-Box-text' style='display: none;' title="Edit Text Box">
    <p id="texttitle" class="pop-up-copy">title</p><p class="pop-up-inputs"><input type='text' /></p>
    <p class="pop-up-copy">TextBox Placeholder</p><p class="pop-up-inputs"><input id="textBox" type='text' /></p>
    <div class="submit"><button id="subimt" class="submit">Submit</button></div>
</div>

编辑位于此html替换中:

case 'btntype_text':
    jQuery('.ui-widget-content .' + fieldClass).html("
           <div class='drop-blank'>
              <p>Text Box</p>
              <div class='li-float'>
                  <input id='textPlaceholder' type='text' placeholder='Text' disabled/>
              </div>
              <div class='text-edit'></div>
              <div class='delete'></div>
           </div>");
    fieldType = "text";
    break;

解决方法

假设您的命名约定是一致的,您可以这样做:

$('div.ui-widget-content').on("click","[class$=edit]",function () {
     var input = jQuery(this).html("");
     $(".pop-up-Box-" + this.className.match(/(\w+)-edit/)[1]).dialog(input);
});

我假设你想要捕获以“edit”结尾的类,所以我们使用了end-with选择器并使用一些基本的正则表达式来获取特定的类名.

@H_403_44@

大佬总结

以上是大佬教程为你收集整理的我是否使用开关或其他方式来简化此操作? jQuery的全部内容,希望文章能够帮你解决我是否使用开关或其他方式来简化此操作? jQuery的所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。