Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/388.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
Javascript 单击“范围”后打开文本字段无效_Javascript_Jquery_Edit In Place - Fatal编程技术网

Javascript 单击“范围”后打开文本字段无效

Javascript 单击“范围”后打开文本字段无效,javascript,jquery,edit-in-place,Javascript,Jquery,Edit In Place,我无法使用JavaScript/jQuery创建就地编辑功能。我无法使用插件editinplace,因为我需要在其上放置一个日期选择器。由于某些奇怪的原因,我下面的代码不起作用: function editImpfDatumImpfung1Clicked(sender) { var sText = $(this).text(); var sId = $(this).attr("id"); $(this).attr("id", "tobechanged"); $(t

我无法使用JavaScript/jQuery创建就地编辑功能。我无法使用插件editinplace,因为我需要在其上放置一个日期选择器。由于某些奇怪的原因,我下面的代码不起作用:

function editImpfDatumImpfung1Clicked(sender)
{
    var sText = $(this).text();
    var sId = $(this).attr("id");
    $(this).attr("id", "tobechanged");
    $(this).after('<input type="text" id="' + sId + '" value="' + sText + '" />');
    $(this).remove();
    bImpfung1Clicked = true;
    $("#" + sId).focus();
    $("#" + sId).datepicker(datepickerOptions);

    if (bFirstRegisterImpfung1 === true)
    {
        firstRegisterImpfung1();
        bFirstRegisterImpfung1 = false;
    }
}

$(document).ready(function()
{
    $elem = $("span[id^='impfung_1['");

    if ($elem.length > 0)
    {
        bFirstRegisterImpfung1 = true;
        $elem.click(editImpfDatumImpfung1Clicked);
    }
});

谢谢你的建议。

我想你在以下几行中有一个打字错误:

$elem = $("span[id^='impfung_1['");
请尝试以下方法:

$elem = $("span[id^='impfung_1']");

控制台上的任何错误提供错误将有助于解决您的问题。您能否提供一个?相关/代表性HTML是什么?以及单个报价?
$elem = $("span[id^='impfung_1']");